mirror of
https://github.com/fergalmoran/snapp.git
synced 2025-12-22 09:41:45 +00:00
17 lines
521 B
TypeScript
17 lines
521 B
TypeScript
import { env } from '$env/dynamic/private';
|
|
import { existsSync } from 'fs';
|
|
import { readFile } from 'fs/promises';
|
|
|
|
export default async function getLanguage() {
|
|
try {
|
|
const exists = existsSync(`${env.LOCALIZATION_FOLDER}/${env.DEFAULT_LANG}.json`);
|
|
if (!exists) return [];
|
|
const jsonContent = JSON.parse(
|
|
await readFile(`${env.LOCALIZATION_FOLDER}/${env.DEFAULT_LANG}.json`, 'utf8')
|
|
);
|
|
return jsonContent;
|
|
} catch (error: any) {
|
|
console.error(`Error loading translation file: ${error.message}`);
|
|
}
|
|
}
|