// Lists every English string the translated pages need, and which ones a dictionary still lacks. // node scripts/i18n-extract.mjs → counts per language // node scripts/i18n-extract.mjs es out.json → writes the missing Spanish strings as {english: ""} import { readFile, writeFile } from 'node:fs/promises'; import { page } from '../src/layout.mjs'; import { JS_STRINGS, mapStrings } from '../src/i18n.mjs'; const pages = ['home', 'about', 'portfolio', 'consulting', 'marketing', 'business-setup', 'business-optimization', 'supply-chain', 'cybersecurity', 'education', 'fractional', 'contact', 'book', 'press']; const strings = new Set(); for (const name of pages) { const def = (await import(`../src/pages/${name}.mjs`)).default; mapStrings(page(def, 'es'), (s) => (strings.add(s), s)); } JS_STRINGS.forEach((s) => strings.add(s)); const [locale, outFile] = process.argv.slice(2); for (const l of locale ? [locale] : ['es', 'ar']) { const dict = JSON.parse(await readFile(new URL(`../src/i18n/${l}.json`, import.meta.url), 'utf8')); const todo = [...strings].filter((s) => !Object.hasOwn(dict, s)); const unused = Object.keys(dict).filter((k) => !strings.has(k)); console.log(`${l}: ${strings.size} strings, ${todo.length} missing, ${unused.length} unused`); if (outFile) await writeFile(outFile, JSON.stringify(Object.fromEntries(todo.map((s) => [s, ''])), null, 1) + '\n'); }