React · i18n · TypeScript · Frontend

Multilingual React Apps with i18next: Setup, Namespaces and SEO

Multilingual React apps with i18next: setup, namespaces for code splitting, plurals and dates, language detection, TypeScript type safety and SEO-friendly URLs.

Sander Yazıcıoğlu Published: 2 min read Türkçe oku

Multilingual React Apps with i18next: Setup, Namespaces and SEO

The desktop interface of this site is written in React and switches between Turkish and English. I used i18next before on health-tourism projects whose interfaces went up to five languages. Here is the outline of a setup that doesn't fall apart as it grows.

Setup

npm install i18next react-i18next i18next-browser-languagedetector
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import tr from './locales/tr/common.json';
import en from './locales/en/common.json';

i18n.use(LanguageDetector).use(initReactI18next).init({
  resources: { tr: { common: tr }, en: { common: en } },
  fallbackLng: 'en',
  supportedLngs: ['tr', 'en'],
  defaultNS: 'common',
  interpolation: { escapeValue: false }
});

React already escapes output, so escapeValue: false is safe.

Usage

const { t, i18n } = useTranslation();
return (
  <>
    <h1>{t('welcome', { name: user.firstName })}</h1>
    <button onClick={() => i18n.changeLanguage('tr')}>Türkçe</button>
  </>
);

Split with namespaces

One giant JSON file is hard to maintain and downloads every translation up front. Create namespaces per screen or feature (common, settings, checkout) and load only what's needed with i18next-http-backend or dynamic import().

Plurals and formatting

i18next supports plural forms via Intl.PluralRules:

{ "files_one": "{{count}} file", "files_other": "{{count}} files" }

Languages such as Polish or Arabic have many plural forms, so structure keys this way from the start. Use Intl.DateTimeFormat and Intl.NumberFormat for dates and currency rather than assembling strings by hand.

Don't concatenate sentences

// Wrong: word order differs between languages
t('deleted') + ' ' + count + ' ' + t('items');
// Right
t('deletedItems', { count });

In Turkish the verb comes last; piecemeal concatenation always produces a broken sentence in some language.

Type safety with TypeScript

declare module 'i18next' {
  interface CustomTypeOptions {
    defaultNS: 'common';
    resources: { common: typeof import('./locales/en/common.json') };
  }
}

Typos such as t('welcom') are now caught at compile time. For the background on type tricks like this, see the practical TypeScript generics guide.

SEO: the language belongs in the URL

An SPA that switches language only on the client shows search engines a single language. For content you want indexed, put the language in the URL (/en/...), render separate HTML per language and link the pages with hreflang. On this site the desktop app detects the browser language, while indexable pages and the blog are generated as separate static HTML for each language.

Catch missing translations

  • Log missing keys in development with saveMissing and missingKeyHandler.
  • In CI, run a small script that checks every locale file has the same set of keys.

Conclusion

An i18next setup that is split into namespaces, type safe, never concatenates sentences and carries the language in the URL scales the same way for a second language as for a fifth.

Angular Performance with OnPush and Change Detection

December 2, 2026 · 2 min read

Angular Performance with OnPush and Change Detection

Default versus OnPush change detection in Angular, what triggers an OnPush check, speeding up large lists with track and trackBy, and the most common mistakes.

AngularPerformanceFrontendTypeScript

All articles →