Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
function parseMessageDict(source) {
|
||||
const dict = {};
|
||||
const re = /"([^"\\]+)"\s*:\s*((?:"(?:\\.|[^"\\])*")|(?:`(?:\\.|[^`\\])*`))/gs;
|
||||
let m;
|
||||
while ((m = re.exec(source))) {
|
||||
const key = m[1];
|
||||
const raw = m[2];
|
||||
dict[key] = raw.startsWith("`")
|
||||
? raw.slice(1, -1).replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\n/g, "\n")
|
||||
: JSON.parse(raw);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
const en = parseMessageDict(
|
||||
fs.readFileSync(path.resolve(__dirname, "../src/lib/i18n/messages/en.ts"), "utf8")
|
||||
);
|
||||
const fr = parseMessageDict(
|
||||
fs.readFileSync(path.resolve(__dirname, "../src/lib/i18n/messages/fr.ts"), "utf8")
|
||||
);
|
||||
const phrases = {};
|
||||
for (const [k, v] of Object.entries(en)) {
|
||||
if (fr[k] === v) phrases[v] = true;
|
||||
}
|
||||
const list = Object.keys(phrases);
|
||||
fs.writeFileSync(path.join(__dirname, "_phrases-needed.json"), JSON.stringify(list, null, 2));
|
||||
console.log("unique phrases needed", list.length);
|
||||
Reference in New Issue
Block a user