Pattern: Multi-language apps and sites

Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.

Search terms: localization, i18n, translation, bcp 47, icu message format, plurals, cldr, right to left, fallback language, missing translation check, time zone

Last reviewed:

For agents

1. Problem

Hard-coded text, string concatenation, English-only plurals and fixed date formats make later languages expensive. Right-to-left languages break layouts built with left and right assumptions.

2. Options

Topic Option Upside Downside
Storage Translation rows (key, language, text) (recommended) Add a language without changing the schema Joins or lookups
Storage One column per language Simple at first Schema change per language; many empty cells
Plurals Message format with plural rules (ICU) Correct for languages with several plural forms Learning curve
Plurals if count == 1 in code Quick Wrong for many languages
Dates/numbers Locale data (CLDR) Correct local formats Needs a library

4. Scenarios and edge cases

5. Common mistakes

6. How to audit

Sources