Glossary / Internationalization APIs

Internationalization APIs

The ECMAScript Intl namespace provides locale-sensitive formatting, sorting, plural selection, relative-time output, display names, lists, and text segmentation. It delegates complex language and regional rules to locale data (commonly ICU/CLDR-backed), avoiding fragile hand-written assumptions. An internationalized interface still needs product decisions about locale, input parsing, time zones, fallback, and accessibility.

Core APIs

new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" })
  .format(1234.5); // locale-specific punctuation and currency placement

Formatting is not parsing: NumberFormat does not provide a universal locale-aware parser. Runtime locale data and defaults can differ; specify options for deterministic tests and server rendering. Server/client locale or time-zone mismatch can cause hydration text differences. Feature-detect optional APIs and test important locales, including RTL and non-Latin digits.

Engineering guidance

Use BCP 47 locale identifiers and a documented fallback policy. Keep canonical data separate from display strings. Do not hard-code separators, month names, plural rules, or sort order. Test output semantics, not exact punctuation alone, unless the locale and runtime data are pinned.

Interview questions

  1. Which Intl API sorts text for a locale? Intl.Collator.
  2. Does NumberFormat parse localized numbers? No; it formats them.
  3. Why specify a time zone? To avoid host-dependent results and express the intended display zone.
  4. Why might SSR hydration differ? Server/client locale, time zone, or locale-data versions may differ.

References