Internationalisation

i18n/same-keys

Every locale file has the same keys and placeholders as the source locale, and the plural forms its language needs.

seriousmanualfe-i18n

Why

A missing key shows the raw key or the fallback language to users; a renamed placeholder ({count} in English, {liczba} in Polish) crashes the formatter or prints the braces; a Polish message with only one and other gives wrong forms for 2–4 and 5+.

Fix

Compare key sets and placeholder names of every locale with the source in CI (most i18n libraries have a lint or extract command; a short script that flattens the JSON is enough). For plurals, list the categories each language needs with new Intl.PluralRules(locale).resolvedOptions().pluralCategories and check every plural message has them.

Examples

const keys = (o, p = '') => Object.entries(o).flatMap(([k, v]) => (typeof v === 'object' ? keys(v, `${p}${k}.`) : [`${p}${k}`]))
const missing = keys(en).filter((k) => !keys(pl).includes(k))
if (missing.length) { console.error('pl is missing', missing); process.exit(1) }

Sources

Facts

Id
i18n/same-keys
Severity
serious
Check
manual a person reviews it; the report lists it as a checklist
Applies to
project
Taught by the skill
fe-i18n Internationalisation
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain i18n/same-keys