mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-20 10:04:57 -05:00
Gear ids and translations
This commit is contained in:
23
scripts/utils.ts
Normal file
23
scripts/utils.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user