eb9137b300
- English stays at /, Spanish at /es/ and Arabic at /ar/ (right to left) - EN · ES · AR switch in the header and mobile menu - Pages are written in English; the build translates them through src/i18n/es.json and src/i18n/ar.json, including browser-script strings - rtl.css mirrors the layout and loads Arabic fonts on /ar/ pages - hreflang alternates on every page and a multilingual sitemap - scripts/i18n-extract.mjs lists strings that still need translating Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 lines
1.4 KiB
JavaScript
24 lines
1.4 KiB
JavaScript
// 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');
|
|
}
|