Skip to content

Variant locales

If your project has locales like en-FI alongside en, read this before you conclude something is broken. A 404 on a variant file is the system working.

A locale xx-YY is treated as a sparse override layer if and only if its base language xx is also a locale of the same project.

Project locales en-FI is…
en, et, en-FI a variant — a sparse override layer over en
et, ru, en-FI an ordinary, full translation target

There is no schema column and no checkbox. The relationship is derived from the BCP 47 code by convention, and codes are canonicalised on the way in, so en-fi is stored as en-FI.

A variant exists to say “in Finland we word these six strings differently”. It is not a second full translation. So the publish pipeline emits only non-empty values for variant locales, and clearing a variant value is a meaningful act: a reviewed empty value retracts the override, and the key falls back again.

Falling back means what i18next does for any text a language lacks. It tries the key’s other names in that language first (a lookup with a context, for example, also tries the name without it), then the next language in its lookup order, usually the base locale. Your load, supportedLngs and fallbackLng settings decide that order. For a plural key, each language picks its own form for the count (at a count of 0, pt-PT uses other and pt uses one). Only published text counts: if the base locale has not published that text (it is still waiting for review, say), the lookup goes on to the next language. When its whole lookup finds nothing (including any fallbackNS), i18next returns the default value your code passes to t(), or else the key itself. Publish the base text first if readers of the variant should see it.

Consequences on the CDN:

  • A variant namespace file contains only overridden keys.
  • If a variant overrides nothing in a namespace, that file does not exist.
May legitimately 404
https://cdn.localize.work/your-project/v12/en-FI/common.json

This is also why the editor does not show unfilled variant keys as untranslated work — an unfilled variant key is not a gap, it is the default.

Until a reviewer approves a cleared override, releases keep publishing the old override. So a cleared value waiting for approval is review work: it appears in the review queue (or the translate queue while it is a draft) and the editor labels it Removal not approved.

Blank text saved before a locale became a variant follows the same rules. If you imported pt-BR with empty values and added pt later, the empty values that were not approved yet (draft or translated) now appear as removals to approve. For the blank form itself, approval changes the next release only if the current release has an entry for that key and plural form in that locale, even an empty one: that entry is dropped, and that form falls back. Otherwise the blank adds nothing to the next release, and the entry leaves the queue. Approval covers every form of the key in that language, so any other form of it waiting for review is approved and published too. Empty values that were already approved need nothing more: the next release drops them, and those forms fall back.

A 404 on a namespace file resolves to an empty resource — callback(null, {}) — and i18next’s fallback chain supplies every value from the base locale. No error, no retry, no console noise.

onFailedLoad still fires with status: 404 so you can log it if you want. Filter those out of your error tracker.

Full retry classification:

Response Backend behaviour i18next retries?
2xx data returned —
404, default empty resource no (not an error)
404, strict: true error no
other 4xx error no — retrying a config problem cannot help
5xx error yes
network / parse failure error yes (parse failure: no)

With i18next’s default load: 'all', a variant needs no fallback setting of its own. For lng: 'en-FI', i18next loads both en-FI/common.json (sparse, possibly 404 → empty) and en/common.json, and resolves each key override-first, before it tries any language in fallbackLng.

Two load values change that. With load: 'currentOnly', i18next loads en-FI and then only the languages in fallbackLng, so a variant falls back to your default language rather than its base: with fallbackLng: 'en', an et-ES reader sees English wherever the sparse file has no override. Map each variant to its base:

await i18next.use(LocalizeBackend).init({
load: 'currentOnly',
supportedLngs: ['en', 'en-FI', 'et', 'et-ES', 'ru'],
fallbackLng: {
'en-FI': ['en'],
'et-ES': ['et'],
default: ['en'],
},
backend: {
projectSlug: 'your-project',
cdnBaseUrl: 'https://cdn.localize.work',
},
});

With load: 'languageOnly', i18next drops the region from the requested language: it looks a requested en-FI up as en, and loads en-FI only if fallbackLng names it. Do not use it with variant locales.

If you do not use variants and would rather a missing file fail loudly, set strict: true. A 404 then calls back with an error and no retry:

backend: { /* … */ strict: true }

Do not set this on a project that has variant locales. Every namespace a variant does not override will hard-fail.