mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-29 05:44:46 -05:00
24 lines
580 B
TypeScript
24 lines
580 B
TypeScript
import path from "node:path";
|
|
import fs from "node:fs";
|
|
|
|
const LANG_DICTS_PATH = path.join(__dirname, "dicts", "langs");
|
|
|
|
export async function loadLangDicts() {
|
|
const result: Array<
|
|
[langCode: string, translations: Record<string, string>]
|
|
> = [];
|
|
|
|
const files = await fs.promises.readdir(LANG_DICTS_PATH);
|
|
for (const file of files) {
|
|
if (file === ".gitkeep") continue;
|
|
|
|
const translations = JSON.parse(
|
|
fs.readFileSync(path.join(LANG_DICTS_PATH, file), "utf8")
|
|
);
|
|
|
|
result.push([file.replace(".json", ""), translations]);
|
|
}
|
|
|
|
return result;
|
|
}
|