Sub topic 1
What Internationalisation Involves and What Breaks Without It
An app that works for one language usually hides assumptions about language, text length, number formats, and reading direction. Internationalisation means finding those assumptions and replacing them with explicit, replaceable parts. This chapter defines the terms, shows the failures that hard-coded text and formats cause, and maps the work the rest of the tutorial covers.
Prerequisites
This chapter assumes you have:
- Working knowledge of React function components and hooks.
- Basic JavaScript or TypeScript, including ES modules and async/await.
- Familiarity with npm and a bundler such as Vite or webpack.
- Basic HTML and CSS.
You do not need any i18n library knowledge yet. Later chapters introduce react-i18next. This chapter uses only React and the browser's built-in Intl objects.
Internationalisation and localisation
The two terms describe different jobs, usually done by different people.
- Internationalisation (i18n) is the engineering work that makes an app able to support many languages and regions. The name comes from "i", 18 letters, "n". It is done once, in code.
- Localisation (l10n) is the work of adapting the app for one specific locale: translating text, choosing formats, and sometimes changing images or examples. It is done once per locale, often by translators who never open the code.
Good i18n makes l10n cheap. Adding Polish should mean adding a translation file, not editing components.
A third term is locale: a language plus optional region and other preferences, such as German as used in Germany versus Switzerland. The next chapter covers how locales are identified.
What breaks without it
Each failure below comes from a specific assumption. Knowing them helps you recognise the same problem in code you review.
Text fixed in the source
If the sentence "Hello" is a literal in JSX, a translator needs a developer and a rebuild to change it. The fix is a lookup by key, covered in the chapters on message catalogs and useTranslation.
Sentences built by concatenation
Joining fragments assumes every language orders words like English:
<p>{count} items in {place}</p>In another language the place may need to come first, or the noun may change form depending on the number. A translator sees only the fragments " items in " and cannot reorder them. A message needs to be one complete string with named placeholders.
Plural forms
The usual English fix is count === 1 ? 'item' : 'items'. That handles exactly two categories, and many languages have different numbers of them. The Intl.PluralRules object reports the categories for a language:
const english = new Intl.PluralRules('en');
const polish = new Intl.PluralRules('pl');
const arabic = new Intl.PluralRules('ar');
const japanese = new Intl.PluralRules('ja');
console.log(english.select(1), english.select(2)); // one other
console.log(polish.select(1), polish.select(2), polish.select(5)); // one few many
console.log(arabic.select(0), arabic.select(2), arabic.select(11)); // zero two many
console.log(japanese.select(1)); // otherEnglish has two forms, Polish four, Arabic six, and Japanese one. A ternary on count === 1 produces wrong grammar in all but English.
Numbers, currencies, and dates
The same value is written differently around the world. This script formats one number and one date under several locales:
const n = 1234567.891;
const d = new Date(2026, 11, 2); // months are zero-based: 11 is December
for (const locale of ['en-US', 'de-DE', 'en-IN']) {
console.log(locale, new Intl.NumberFormat(locale).format(n));
}
// en-US 1,234,567.891
// de-DE 1.234.567,891
// en-IN 12,34,567.891
for (const locale of ['en-US', 'en-GB', 'de-DE']) {
console.log(locale, new Intl.DateTimeFormat(locale).format(d));
}
// en-US 12/2/2026
// en-GB 02/12/2026
// de-DE 2.12.202612/2/2026 is 2 December in the US and would be read as 12 February by a reader in the UK. Hard-coded $ signs, toFixed(2), and manual date strings all carry the same risk. The chapter on formatting covers Intl in detail.
Reading direction
Arabic, Hebrew, Persian, and Urdu are written right to left (RTL). A layout that uses margin-left, float: left, or text-align: left places elements on the wrong side for those readers. Without the dir attribute on the document, punctuation and mixed text also render in the wrong order.
Text length
Translated text is rarely the same length as the English original. German words are often longer, and some scripts need more line height. Fixed-width buttons, truncated labels, and single-line headers clip or overflow. This is a layout problem, not a translation problem, so it must be handled in the design.
Other assumptions
Several smaller assumptions fail in similar ways:
- Sorting. Alphabetical order differs by language, so
array.sort()on names gives wrong results.Intl.Collatorsorts by locale rules. - Case conversion.
toUpperCase()follows Unicode defaults, which are wrong for some languages, such as Turkish dotted and dotless "i".toLocaleUpperCase(locale)takes the language into account. - Names and addresses. Forms that require a first and last name or a five-digit postal code reject valid input from other regions.
A component that breaks
This component works for an English-speaking US user and fails for others in at least four ways:
type CartSummaryProps = {
name: string;
count: number;
total: number;
deliveryDate: Date;
};
export function CartSummary({ name, count, total, deliveryDate }: CartSummaryProps) {
return (
<section style={{ textAlign: 'left' }}>
<h1>Hello, {name}!</h1>
<p>{count} item{count === 1 ? '' : 's'} in your cart</p>
<p>Total: ${total.toFixed(2)}</p>
<p>Delivery by {deliveryDate.toLocaleDateString()}</p>
</section>
);
}Going through it line by line:
Hello, {name}!is a literal string, so it cannot be translated without editing the component.- The ternary on
countencodes the English plural rule and also splits one sentence across code and markup. $andtoFixed(2)assume US dollars and a period as the decimal separator.toLocaleDateString()with no argument uses the browser's default locale. That is not necessarily the language the user chose in your app, so the date can disagree with the rest of the page.textAlign: 'left'is wrong for RTL languages.
The tutorial rebuilds this component step by step. By the end, every line above is replaced by a catalog lookup, an Intl formatter, or a direction-aware style.
What the work covers
The chapters that follow map onto these areas:
| Area | Problem it solves | Where it appears |
|---|---|---|
| Locale identification | Knowing which language and region a user wants | Language tags, fallback, detection |
| Message catalogs | Moving text out of components | Keys, JSON catalogs, key management |
| Messages with variables | Word order, plurals, embedded markup | Interpolation, plurals, `Trans` |
| Locale-aware formatting | Numbers, currencies, dates, lists | `Intl` APIs |
| Runtime switching | Changing language without a reload | `changeLanguage`, `lang` and `dir` |
| Layout | RTL and text expansion | CSS logical properties |
| Delivery and quality | Bundle size, missing keys, tests, SSR | Lazy loading, checks, URLs |
Edge cases to keep in mind
- A language is not a country. Spanish in Mexico and in Spain differ in vocabulary and formats. Choosing by country flag is a common UX mistake.
- A locale can change formats without changing language.
en-USanden-GBshare a language but not date order or spelling. - Currency is separate from locale. A German-speaking user can see prices in Swiss francs. Format with the user's locale and the price's currency, not the other way round.
- Not every string is user-facing. Log messages, analytics event names, and API enum values should stay stable and untranslated. Translate only what a person reads.
- Pseudo-locales help testing. A fake locale that wraps each string in brackets and adds accents makes untranslated text and clipped layouts easy to spot before real translations exist.
Exercise
A teammate writes {count === 1 ? 'file' : 'files'} in JSX and says it is fine because "we only ship English for now". Give two reasons this still makes later localisation harder, and name the better approach for the plural.
Show answer
First, the plural rule and part of the sentence live in component code, so a translator cannot change them without a developer, and each new language needs a code change instead of a new catalog. Second, the ternary encodes only English's two categories, so languages such as Polish (one, few, many, other) or Arabic (six categories) cannot be expressed. The better approach is a single complete message in a catalog with a count placeholder, where the plural category is chosen by Intl.PluralRules for the active locale, as i18next does with _one and _other style keys.