Gear ids and translations

This commit is contained in:
Kalle
2022-08-28 18:05:36 +03:00
parent 3c67aeac63
commit ea9fda5cb5
6 changed files with 326 additions and 3 deletions

23
scripts/utils.ts Normal file
View 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;
}