Lesson 1 of 9 · 24m
Locale Identity Is Not a Country Flag
Model language, script, region, and variants as structured locale identity, then design fallback chains that fail predictably.
The fastest way to make a mess of internationalization is to treat locale as a two-letter country code. I still see databases with a country column feeding language selection, as if every user in Switzerland speaks German and every user in Canada wants English. Real locale identity is a language negotiation problem, not a geography problem.
Use real locale identifiers
Modern platforms use BCP 47 language tags, usually built from language, script, region, and Unicode extensions:
en-US English as used in the United States
en-GB English as used in the United Kingdom
pt-BR Brazilian Portuguese
zh-Hant-TW Traditional Chinese as used in Taiwan
sr-Latn Serbian in Latin script
es-419 Spanish as used in Latin America and the CaribbeanThe tag carries more than vocabulary. It influences plural rules, date order, calendar, digit shaping, collation, capitalization, hyphenation, and text direction. Do not invent tags like en-UK or parse them with string splitting assumptions you have not validated.
Language, region, and script are independent decisions
A user can want English copy, a German number format, and a Tokyo time zone. A Chinese user may want Simplified or Traditional script independent of where their IP address appears to be. Region often controls conventions; script controls writing system; language controls translation. They overlap, but they are not interchangeable.
type UserLocalePreferences = {
languageTag: "zh-Hant-TW";
timeZone: "Asia/Taipei";
hourCycle?: "h12" | "h23";
};Store the user's selected language tag exactly enough to reconstruct intent. Normalize for lookup, but do not destroy meaningful script or region distinctions.
Fallback is a chain, not a coin flip
If es-MX is unavailable, a sensible message lookup might try:
es-MX -> es -> root/defaultIt should not silently jump to es-ES unless your product intentionally chooses that regional fallback. zh-Hant-TW may fall back through zh-Hant before generic zh, but a naive zh-CN fallback changes script and can feel wrong even when the words are technically readable.
Do not derive preference from IP address
IP geolocation tells you network location, not language. Travel, VPNs, corporate egress, migration, multilingual households, and shared devices make it unreliable as a personalization source. Use it only as a weak default for first render, never as a replacement for an explicit setting.
Design for mixed-language output
Production systems rarely achieve perfect coverage. A settings page can contain translated navigation, an untranslated legal string, and user-generated content in a third language. That is not automatically a bug. The design mistake is pretending the UI has one global language when each string, document, and direction run may need its own metadata.
Field notes
enis a language, not a complete formatting locale. Pick a concrete default such asen-USonly when the product truly has that convention.- Country flags are political and ambiguous. Label language choices with endonym names such as
Deutsch,Français,العربية, and日本語. - Locale parsing belongs in a library. Do not regex BCP 47 tags unless you enjoy subtle invalid-tag bugs.
- Time zone is not part of language.
fr-FRdoes not tell you whether the user is in Paris, Montreal, or Dakar.
Was this lesson helpful?