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,32 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createRequire } from "node:module";
|
||||
|
||||
// Re-parse PACKS by evaluating gen script is hard; instead diff en vs es.
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const messagesDir = path.resolve(__dirname, "../src/lib/i18n/messages");
|
||||
|
||||
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.join(messagesDir, "en.ts"), "utf8"));
|
||||
const es = parseMessageDict(fs.readFileSync(path.join(messagesDir, "es.ts"), "utf8"));
|
||||
const missing = {};
|
||||
for (const [k, v] of Object.entries(en)) {
|
||||
if (es[k] === v) missing[k] = v; // likely untranslated (same as en) OR intentionally same
|
||||
}
|
||||
// Prefer keys not in our known translated set — dump all where es === en
|
||||
fs.writeFileSync(path.join(__dirname, "_missing.json"), JSON.stringify(missing, null, 2), "utf8");
|
||||
console.log(`candidates same-as-en: ${Object.keys(missing).length}`);
|
||||
Reference in New Issue
Block a user