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,45 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { EXTRA as EXTRA_COMMON, SAME_AS_EN } from "./locale-extra.mjs";
|
||||
import { EXTRA as EXTRA_ES } from "./locale-extra-es.mjs";
|
||||
import { EXTRA as EXTRA_REST } from "./locale-extra-rest.mjs";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const enPath = path.resolve(__dirname, "../src/lib/i18n/messages/en.ts");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Import PACKS by re-running merge logic inline is hard — load from written es/fr instead.
|
||||
const en = parseMessageDict(fs.readFileSync(enPath, "utf8"));
|
||||
const esFile = parseMessageDict(
|
||||
fs.readFileSync(path.resolve(__dirname, "../src/lib/i18n/messages/es.ts"), "utf8")
|
||||
);
|
||||
const frFile = parseMessageDict(
|
||||
fs.readFileSync(path.resolve(__dirname, "../src/lib/i18n/messages/fr.ts"), "utf8")
|
||||
);
|
||||
|
||||
const esMissing = {};
|
||||
const frMissing = {};
|
||||
for (const [k, v] of Object.entries(en)) {
|
||||
if (SAME_AS_EN.has(k)) continue;
|
||||
if (esFile[k] === v) esMissing[k] = v;
|
||||
if (frFile[k] === v) frMissing[k] = v;
|
||||
}
|
||||
fs.writeFileSync(path.join(__dirname, "_es-still-en.json"), JSON.stringify(esMissing, null, 2));
|
||||
fs.writeFileSync(path.join(__dirname, "_fr-still-en.json"), JSON.stringify(frMissing, null, 2));
|
||||
console.log("es still en", Object.keys(esMissing).length);
|
||||
console.log("fr still en", Object.keys(frMissing).length);
|
||||
console.log("en total", Object.keys(en).length);
|
||||
Reference in New Issue
Block a user