DUNGEONS-34: implement Webka local streaming app
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
37
frontend/scripts/check-locales.mjs
Normal file
37
frontend/scripts/check-locales.mjs
Normal file
@@ -0,0 +1,37 @@
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { join } from "node:path";
|
||||
const root = fileURLToPath(new URL("../", import.meta.url));
|
||||
const flatten = (value, prefix = "") =>
|
||||
Object.entries(value).flatMap(([key, v]) =>
|
||||
typeof v === "object"
|
||||
? flatten(v, `${prefix}${key}.`)
|
||||
: [`${prefix}${key}`],
|
||||
);
|
||||
const locales = ["en", "ru", "es"].map((code) =>
|
||||
JSON.parse(readFileSync(join(root, `i18n/locales/${code}.json`), "utf8")),
|
||||
);
|
||||
const expected = flatten(locales[0]).sort();
|
||||
for (let i = 1; i < locales.length; i++)
|
||||
if (JSON.stringify(flatten(locales[i]).sort()) !== JSON.stringify(expected))
|
||||
throw Error("Locale key mismatch");
|
||||
const files = (path) =>
|
||||
readdirSync(path, { withFileTypes: true }).flatMap((entry) =>
|
||||
entry.isDirectory()
|
||||
? files(join(path, entry.name))
|
||||
: [join(path, entry.name)],
|
||||
);
|
||||
for (const file of [
|
||||
...files(join(root, "pages")),
|
||||
...files(join(root, "components")),
|
||||
join(root, "app.vue"),
|
||||
]) {
|
||||
for (const match of readFileSync(file, "utf8").matchAll(
|
||||
/\b(?:\$t|t)\(['"]([\w.]+)['"]/g,
|
||||
))
|
||||
if (!expected.includes(match[1]))
|
||||
throw Error(`${file}: Missing ${match[1]}`);
|
||||
}
|
||||
console.log(
|
||||
`${expected.length} keys match in en/ru/es; static template keys verified.`,
|
||||
);
|
||||
Reference in New Issue
Block a user