Locale fallback chain

The ordered list your app walks when a string is missing: try pt-BR, then pt, then English, instead of showing a raw key or an empty box.

if pt-BR is missing, use pt then Englishwhat happens when a translation is missingdefault language fallbacktranslation fallback orderfallback localeit just shows the key name instead of textfalls back to English

See it

Live demo coming soon

What it is

A fallback chain is the ordered list your i18n layer walks when a key is missing: pt-BR, then pt, then en. The default chain comes from chopping the BCP 47 tag from the right (es-MX to es to the default locale), and you override it when the tree lies about reality: zh-HK should fall back to zh-Hant before zh-Hans, and pt-BR often reads better falling straight to English than to pt-PT.

Resolve per key, not per file. Per-key fallback fills individual holes so a half-translated locale still ships; per-file fallback means one missing string drops the whole screen back to English. This is what lets you launch a locale before it is fully translated and backfill, and what makes over-the-air translation updates safe.

Gotcha: silent fallback is a bug factory, because a screen that looks fine to you has been quietly English for six months. Count and report every miss, then pick one coverage policy per locale rather than two contradictory ones. Either CI enforces complete coverage for the locales you call done, or a locale declares a coverage threshold plus an explicit allowlist of known-missing keys, with fallback telemetry burning the list down. A chain that permits an 80% launch and a CI gate that fails on any missing key cannot both be true. Remember that fallback applies to the text only: dates, numbers, and currency must still format in the user's actual locale even when the sentence around them came from English. And an English string dropped inside a right-to-left layout needs bidi isolation or the punctuation jumps.

Ask AI for it

Implement per-key locale fallback in this app's i18n layer. Resolve a key by walking an ordered chain derived from the BCP 47 tag (pt-BR to pt to en) with support for explicit overrides per locale, returning the first catalog that has the key rather than falling back a whole file. When every step misses, render the source-language string, never the raw key. Log each fallback hit with the key, requested locale, and locale that served it. Add a CI check that enforces one declared policy per locale: complete coverage for locales marked complete, or a declared coverage threshold with an explicit allowlist of known-missing keys for locales still backfilling. Do not write a gate that both permits partial coverage and fails on any missing key.

You might have meant

translation keymessage cataloglanguage negotiationlocalelocalization testing