Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
25 lines
718 B
JavaScript
25 lines
718 B
JavaScript
import fs from "node:fs";
|
|
import { EXTRA } from "./locale-extra-es.mjs";
|
|
|
|
function parse(s) {
|
|
const d = {};
|
|
const re = /"([^"\\]+)"\s*:\s*((?:"(?:\\.|[^"\\])*")|(?:`(?:\\.|[^`\\])*`))/gs;
|
|
let m;
|
|
while ((m = re.exec(s))) {
|
|
const raw = m[2];
|
|
d[m[1]] = raw.startsWith("`")
|
|
? raw.slice(1, -1).replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\n/g, "\n")
|
|
: JSON.parse(raw);
|
|
}
|
|
return d;
|
|
}
|
|
|
|
const en = parse(fs.readFileSync("../src/lib/i18n/messages/en.ts", "utf8"));
|
|
const map = {};
|
|
for (const [k, es] of Object.entries(EXTRA.es)) {
|
|
const e = en[k];
|
|
if (e) map[e] = { ...(map[e] || {}), es };
|
|
}
|
|
fs.writeFileSync("_phrase-seed.json", JSON.stringify(map, null, 2));
|
|
console.log(Object.keys(map).length);
|