Check that translations.en.json and translations.pt.json have identical key structures, report missing keys, and optionally compile i18n. Run before every deploy.
Diff the key structure of both translation files and report any missing or extra keys.
yarn deploy)add-experiencei18n/translations.en.json but not in i18n/translations.pt.jsoni18n/translations.pt.json but not in i18n/translations.en.jsonnpm run i18n (extract:i18n + compile:i18n) if @formatjs/cli is in useRead and . Recursively flatten each file into a set of dot-separated leaf key paths. Example:
i18n/translations.en.jsoni18n/translations.pt.jsoni18n./developer.experiences.liftventures.title
i18n./developer.experiences.liftventures.company
...
missing_in_pt = keys_en - keys_pt
missing_in_en = keys_pt - keys_en
If both sets are empty → ✅ Translation files are in sync.
If there are differences, list them clearly:
❌ Missing in translations.pt.json:
- i18n./developer.experiences.anthropic.title
- i18n./developer.experiences.anthropic.company
- i18n./developer.experiences.anthropic.time
- i18n./developer.experiences.anthropic.description
❌ Missing in translations.en.json:
(none)
Then offer to fill in the missing PT keys by asking the user for the Portuguese values for each missing leaf.
If the user confirms, run:
npm run i18n
This runs extract:i18n then compile:i18n via @formatjs/cli. Note: this project currently uses next-export-i18n with the hand-written translation files, so npm run i18n may not be needed unless react-intl message extraction is in use. Confirm with the user before running.
i18n/translations.en.jsoni18n/translations.pt.jsonYou can also verify sync by running this in the project root:
node -e "
const en = require('./i18n/translations.en.json');
const pt = require('./i18n/translations.pt.json');
const flatten = (obj, prefix='') =>
Object.entries(obj).flatMap(([k, v]) =>
typeof v === 'object' && v !== null
? flatten(v, prefix ? prefix+'.'+k : k)
: [prefix ? prefix+'.'+k : k]
);
const enKeys = new Set(flatten(en));
const ptKeys = new Set(flatten(pt));
const missingPt = [...enKeys].filter(k => !ptKeys.has(k));
const missingEn = [...ptKeys].filter(k => !enKeys.has(k));
if (missingPt.length) console.log('Missing in PT:\n' + missingPt.join('\n'));
if (missingEn.length) console.log('Missing in EN:\n' + missingEn.join('\n'));
if (!missingPt.length && !missingEn.length) console.log('✅ In sync');
"