Key points
- By default next-intl logs an error and renders namespace.key when a message is missing
- i18next falls back to fallbackLng, and treats an empty string as a valid translation by default
- TypeScript types are generated from the default-language file, so they cannot see gaps in ja.json
- When comparing files, group i18next plural suffixes such as _one and _other under their base key
What key parity means
A multilingual app keeps one message file per language, and every file must hold the same keys. In practice the source file, usually en.json, grows with each feature, and ja.json falls behind. When a key is missing, the Japanese screen shows a raw key or English text. The opposite also happens: a string is removed from the UI, its key stays in ja.json, and translators keep maintaining text nobody sees. Neither problem breaks the build, which is why both tend to reach production.
| State | What users see | How to detect |
|---|---|---|
| Missing (in en, not in ja) | A raw key or another language | Difference of key sets |
| Extra (in ja, not in en) | Nothing, but translators waste effort | Difference of key sets |
| Empty translation | A blank where text should be | Value is an empty string |
| Placeholder mismatch | A value that never appears, or a formatting error | Compare names such as {name} |
| Type mismatch | A string where an object was expected, or the reverse | Compare leaf versus branch |
What next-intl does with a missing message
According to the next-intl configuration docs, when a message is missing or fails to format, an error is printed to the console by default and the string namespace.key is rendered instead, so the app keeps running. You can change both behaviors in i18n/request.ts. getRequestConfig accepts onError and getMessageFallback. Inside onError, comparing error.code with IntlErrorCode.MISSING_MESSAGE separates missing translations, which are expected during development, from real errors that should go to your error tracker.
import {getRequestConfig} from 'next-intl/server';
import {IntlErrorCode} from 'next-intl';
export default getRequestConfig(async () => {
// loading locale and messages is omitted
return {
locale,
messages,
onError(error) {
if (error.code === IntlErrorCode.MISSING_MESSAGE) {
console.error(error);
} else {
reportToErrorTracking(error);
}
}
};
});The same page notes that onError and getMessageFallback are not automatically inherited by Client Components, so you pass them to the client provider as well if you want the same handling there. It also mentions providing fallback messages, for example by merging the default locale's messages with the current locale's. Merging keeps the screen intact, but it also hides the gap: the Japanese UI quietly shows English. You still need a separate way to list what is missing.
What i18next does with a missing key
The i18next configuration options describe fallbackLng as the language to use if translations in the user's language are not available; its default is 'dev'. Setting saveMissing to true calls the backend's save function when a key is not found, and missingKeyHandler lets you add custom handling, but only when saveMissing is true. parseMissingKeyHandler decides what to display for a missing key.
One default deserves attention: returnEmptyString is true, which means an empty string is accepted as a valid translation. If a translation tool or a teammate leaves "" in ja.json, i18next does not fall back to English; it renders nothing. Empty values therefore need their own check, separate from missing keys.
| Topic | next-intl | i18next |
|---|---|---|
| Key not found | Console error, renders namespace.key | Looks up the fallbackLng language |
| Hook for missing keys | onError with IntlErrorCode.MISSING_MESSAGE | saveMissing plus missingKeyHandler |
| Customizing displayed text | getMessageFallback | parseMissingKeyHandler |
| Empty string | Not described | Valid translation by default (returnEmptyString: true) |
What TypeScript can and cannot catch
Both libraries offer type safety for keys. next-intl lets you augment AppConfig with a Messages type taken from your default messages file; unknown keys and missing arguments then become type errors. i18next describes augmenting CustomTypeOptions with resources imported from the default language's namespaces.
import messages from './messages/en.json';
declare module 'next-intl' {
interface AppConfig {
Messages: typeof messages;
}
}In both cases the type comes from one file, the default language. That is the right design for catching typos in code, because code is written against the source language. It also means the compiler has no idea whether ja.json contains the key. A project can type-check perfectly and still ship a Japanese screen full of raw keys. Gaps between language files are found by comparing the files themselves.
Comparing the files
Flatten each nested JSON file into a list of dotted keys such as Settings.profile.title, then take set differences. The script below runs on plain Node.js with no dependencies. It exits with a non-zero code when keys are missing, so it can fail a CI job.
import fs from 'node:fs';
const read = (p) => JSON.parse(fs.readFileSync(p, 'utf8'));
const flat = (obj, prefix = '') =>
Object.entries(obj).flatMap(([k, v]) =>
v && typeof v === 'object' ? flat(v, `${prefix}${k}.`) : [`${prefix}${k}`]
);
const en = new Set(flat(read('messages/en.json')));
const ja = new Set(flat(read('messages/ja.json')));
const missing = [...en].filter((k) => !ja.has(k));
const extra = [...ja].filter((k) => !en.has(k));
console.log({missing, extra});
process.exit(missing.length > 0 ? 1 : 0);This is enough for next-intl projects that use ICU plurals inside a single message. Extend it to report empty strings and to compare the placeholder names in each pair of values, because a translation that says {namae} instead of {name} passes a key comparison but never shows the value.
i18next projects often split resources into one file per namespace, for example locales/en/common.json and locales/ja/common.json. In that layout, compare each pair of files separately and prefix every key with its namespace in the report. i18next's default namespace separator is a colon, so a report line such as common:save matches how the key is written in code and is easy to search for.
Watch out for i18next plural keys
i18next writes plurals as separate keys with suffixes, such as file_one and file_other. English uses the one and other categories, but under the Unicode CLDR rules Japanese has only other. A naive comparison therefore reports file_one as missing from ja.json, even though Japanese never needs it. Before comparing, strip the plural suffixes and group the keys under their base key; for Japanese, the presence of the _other key is sufficient.
A routine that keeps files in step
Pick the reference file
Use the language in which keys are added first, usually English, as the source of truth.
Fail on missing keys
Treat missing keys as errors and extra keys as warnings, so the build fails only when users would see a problem.
Check values too
Report empty strings and differences in placeholder names, not only key names.
Run it on every pull request
Run the comparison in CI so the gap appears in the same pull request that added the key.
Teams that translate in batches, for example once per release, can relax the rule on feature branches and enforce it on the release branch. The important part is that the list of missing keys is produced automatically and reaches whoever translates.
FAQ
If we fall back to English, do we still need to look for missing keys?
Yes. The screen will not break, but Japanese users will see English. Keep the fallback as a safety net and still list the missing keys so they get translated.
Can we delete extra keys right away?
Keys built at runtime, such as t(`status.${s}`), may not show up in a code search. Confirm how a key is used before removing it.
Do the type-safety features replace a parity check?
No. They check code against the default-language file. A parity check compares the language files with each other. You want both.
How YakuCheck helps
YakuCheck reports a missing key (YC001), an extra key (YC002), a placeholder or tag mismatch (YC003), an empty translation (YC004) and a type mismatch (YC006) as separate rules.
It groups i18next _one and _other keys under their base key and treats _other alone as complete for Japanese (YC007). ICU plurals in next-intl are complete with other alone.
Rule checks run locally or in CI and never send your files anywhere.
Sources
- next-intl: Request configuration (onError, getMessageFallback)
- next-intl: TypeScript augmentation
- i18next: Configuration Options
- i18next: TypeScript
- i18next: Plurals
- Unicode CLDR: Language Plural Rules
Last checked
Library behavior changes between versions. Check the official documentation for the version you use.