i18n at Production Scale

Load dictionaries per language and namespace with import() or i18next-http-backend, but measure first: in our Vite 8.0.8 build the card's dictionaries are…

Mrs. Sri's page now has four languages, and the guests keep coming. The question shifts from "is the translation right?" to "how does the dictionary reach the guest?". Each guest downloads only their language, files are cached for a long time on a CDN, and there's a fallback when a bundle fails to load. Server and browser agree on the language, and missing keys get reported. That's i18n at production scale: sending the right dictionary to the right guest, fast, and staying up when something fails. The Mist Homestay guidebook in four languages works the same way. A guest from Tokyo only needs the Japanese book, not all four. The books sit on the nearest front-desk shelf (the CDN), the cover carries an edition number (a content hash) so an old edition never gets mixed up, and the front desk notes every time a guest asks for a page that isn't there (monitoring).

Bundles per language: measured, not guessed

// src/i18n.js: en-US (the source language) ships in the main bundle, other languages load when picked.
import resourcesToBackend from 'i18next-resources-to-backend';
import enUS from './locales/en-US/booking.json';

i18next.use(resourcesToBackend((lng, ns) => import(`./locales/${lng}/${ns}.json`))).init({
  lng: document.documentElement.lang, // 'ja-JP', written by the server
  fallbackLng: ['en-US'],
  load: 'currentOnly',            // ask for 'ja-JP' only, not 'ja' as well
  partialBundledLanguages: true,
  resources: { 'en-US': { booking: enUS } },
});

We built this card with Vite 8.0.8. Each dictionary becomes its own chunk with a hash in its name: id-ID 518 bytes (gzip 332), en-US 664 (364), ja-JP 592 (435), ar-EG 1,316 (576). Then we logged which languages i18next 26.4.3 requests for a ja-JP guest: ja-JP only, because en-US, the one language in fallbackLng, is already in the bundle. With every language lazy it requests ja-JP and en-US: the languages in fallbackLng are loaded too, so t() can fall back to them. What a Japanese guest downloads:

Approach Downloaded Bytes gzip
One bundle, all four dictionaries inside index-oBh9CMqz.js 3,014 1,421
Every language lazy entry 2,853 + ja-JP 592 + en-US 664 4,109 2,192
Lazy, en-US in the main bundle (the code above) entry 3,734 + ja-JP 592 4,326 2,250

So for 10 keys, the Japanese guest actually downloads more: as soon as there's an import(), Vite adds about 2 KB of loader code, and the fallback languages come along. The sums flip once there are many languages and big dictionaries: with 20 languages and 2,000 keys each (a linear estimate from our chunk sizes, about 150 KB per language), one bundle is about 3 MB, while a Japanese guest with the last approach downloads about 300 KB. Split per namespace too (booking, admin), and keep the fallbackLng chain short: every fallback language is one more download. Measure your own build.

Caching with content hashes, through a CDN

When a bundle fails to load

i18next.on('failedLoading', (lng, ns, msg) => report('i18n_load_failed', { lng, ns, msg }));
i18next.on('languageChanged', () => {
  const used = i18next.resolvedLanguage;          // the language t() really uses
  document.documentElement.lang = used;
  document.documentElement.dir = i18next.dir(used);
});

Server and browser agree on the language

A server-rendered page writes <html lang="ja-JP"> and Japanese text. If the browser starts i18next with another language, or waits for the dictionary to load first, React's first render differs from the server's HTML: in a production build that's "Minified React error #418" (the Server-side i18n lesson).

// Browser: use the same language and dictionary as the server, without waiting.
const lng = document.documentElement.lang;                    // 'ja-JP', written by the server
const booking = JSON.parse(document.getElementById('i18n-booking').textContent); // the dictionary the server embedded
i18next.init({ lng, fallbackLng: ['en-US'], resources: { [lng]: { booking } }, partialBundledLanguages: true, initAsync: false });

initAsync: false (in i18next 26, the replacement for initImmediate) makes init finish before the first render, since the dictionary is already there.

Monitoring missing keys in production

const seen = new Set();
i18next.init({
  // ...
  saveMissing: true,
  missingKeyHandler: (lngs, ns, key) => {
    const id = `${i18next.language}:${ns}:${key}`;   // the requested language
    if (seen.has(id)) return;                         // one report per key per session
    seen.add(id);
    navigator.sendBeacon('/api/i18n-missing', JSON.stringify({ id, path: location.pathname }));
  },
});

Locale and RTL coverage dashboards

From the same files CI checks (the Translation Workflow lesson), count per locale: translated keys, keys that fell back to fallbackLng this week (from the reports above), and pages with a passing RTL screenshot. For our card: id-ID 10 of 10, ja-JP 10 of 10, ar-EG 20 of 20, plus a passing ar-EG (dir="rtl") screenshot. Set a bar: for example, a language under 95% may not ship.

Adding a fifth language: ko-KR

  1. Add ko-KR to locales in i18next.config.js, then npx i18next-cli extract. Korean has only the other category, so nights_other and total_other.
  2. Add the target language in the TMS. DeepL supports KO, glossaries included; fill the glossary (Terrace Room, Mist Homestay).
  3. Check the formats: Node 22 writes the price as "US$70.00", and new Intl.DisplayNames(['ko'], { type: 'language' }).of('ko') gives "한국어" for the language picker.
  4. Fonts: make sure a Hangul font is in the font-family stack, then run the screenshots.
  5. Routing and SEO: a /ko/ prefix, hreflang="ko", the sitemap, and the list of locales the server negotiates (Accept-Language, Laravel's lang/ko.json).
  6. CI: add ko-KR to the checks, the pseudo-locale and the screenshot matrix. Ship once its coverage clears the bar.

Intl polyfills: only when needed

The web-features 3.42.0 data (October 2026): Intl.PluralRules (Baseline since 2019), Intl.Locale (2020) and Intl.DisplayNames (2021) are "widely available". The new ones: Intl.DurationFormat (Baseline in March 2025) and locale info such as getTextInfo() (July 2026, Firefox 153). Temporal is not Baseline yet (not in Safari). Our card needs no polyfill. If you install one anyway: a forced @formatjs/intl-pluralrules 6.3.15 plus four locales' data adds 70.4 KB (gzip 19.7 KB) to our Vite build, about 23 times the four dictionary chunks (3,090 bytes). Load it with shouldPolyfill() and import(), so modern browsers download nothing.

⚠️ What makes i18n heavy or quietly broken in production

TL;DR: Load dictionaries per language and namespace with import() or i18next-http-backend, but measure first: in our Vite 8.0.8 build the card's dictionaries are just 518 to 1,316 bytes per language, Vite's loader about 2 KB, and i18next also downloads the fallbackLng languages, so a Japanese guest downloads 4,109 bytes lazily against 3,014 from one bundle; lazy loading only wins with many languages and big dictionaries. Hashed file names go out with max-age=31536000, immutable; fixed names with no-cache plus an ETag. A CDN keeps dictionaries close to guests, one URL per language, no Vary: Accept-Language. When a bundle fails, i18next retries (5 times, from 350 ms) on 5xx and network errors, then falls back to fallbackLng: take lang and dir from resolvedLanguage. The server writes lang and embeds the dictionary; the browser starts with the same language and dictionary and initAsync: false. missingKeyHandler only reports keys missing from every language; also report a usedLng that differs from language through returnDetails, once per key. A new language (ko-KR) is a checklist: config, TMS and glossary, formats, fonts, routing and SEO, CI. Intl polyfills are hardly ever needed in 2026; when they are, load them conditionally.

⚡ Measure before going lazy

Guess first: with only 10 keys in the card's dictionaries, does a Japanese guest download less when the dictionaries are lazy-loaded?

More, in fact: 4,109 bytes lazily against 3,014 bytes from one bundle. Vite adds about 2 KB of loader code, and the languages in fallbackLng come along.

Meaning: Lazy loading per language only wins with many languages and big dictionaries. Keep the fallbackLng chain short, and measure your own build.

⚡ Hashed names, through a CDN

Meaning: A file with a hash in its name goes out with Cache-Control: public, max-age=31536000, immutable. A CDN keeps copies on servers close to guests, so a guest in Tokyo gets the Japanese dictionary from a server in Asia. Every language has its own URL, so the cache is per language too.

⚡ Report what falls to another language

Meaning: missingKeyHandler only fires when a key is missing from every language in the chain. To catch a cancel that quietly falls to en-US, compare usedLng from returnDetails with the requested language, and send one report per key per session.

What you will learn