Internationalisation and Localisation
Prepare apps for many languages and regions: message catalogues, plurals, Intl formatting, right-to-left layouts and locale routing.
Intermediate · about 4 hours · difficulty 3/5
Learn first: React, Client-Side Routing
Internationalisation (i18n) is engineering the app so it can be adapted; localisation (l10n) is the adaptation itself: translated text, local formats and cultural conventions. Retrofitting i18n into a large app is painful, so learn the patterns early.
Messages and translations
- Never hard-code user-facing strings. Use keys in message catalogues (JSON per locale) through a library: react-i18next, FormatJS / react-intl, next-intl for Next.js, or Lingui.
- Use the ICU message format for variables, plurals and select:
{count, plural, one {# item} other {# items}}. Languages have different plural rules (Arabic has six forms), so never build sentences by concatenation. - Give translators context (descriptions, screenshots) and never split sentences across keys.
Formatting with Intl
The built-in Intl APIs format per locale without extra libraries: Intl.NumberFormat (numbers, currencies, units), Intl.DateTimeFormat and Intl.RelativeTimeFormat ("3 days ago"), Intl.PluralRules, Intl.ListFormat and Intl.Collator for sorting. Store dates in UTC and format in the user's time zone.
Layout and direction
- Right-to-left languages (Arabic, Hebrew, Urdu): set
dir="rtl"and use logical CSS properties (margin-inline-start,padding-block,inset-inline-end) instead of left and right. - Allow text to expand (German can be 30% longer); avoid fixed-width buttons.
- Set the
langattribute so screen readers pronounce text correctly.
Locale routing and SEO
Use locale prefixes or domains (/en/, /fr/), detect but do not force the user's language, and add hreflang alternates.
Good enough to move on
You can externalise all strings in an app, add a second language with plurals, format dates and currency with Intl and make the layout work in RTL.
Key concepts
- i18n vs l10n
- Message catalogues and keys
- ICU plurals and select
- Intl number, date and relative time formatting
- Right-to-left and logical CSS properties
- react-i18next, FormatJS and next-intl
- Locale routing and hreflang
- Translation workflows
Mini project
Localise your catalogue app into English, Hindi and Arabic: externalised strings with plurals, Intl-formatted prices and dates, a language switcher with locale routes and a correct RTL layout for Arabic.
Check yourself
Why is `count + " items"` wrong for internationalised apps, even after translating the word items?
Free resources
- Intl (MDN)
- react-i18next (i18next)
- FormatJS (FormatJS)