Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 1.21 KB

File metadata and controls

40 lines (26 loc) · 1.21 KB

76. Advanced internationalization

Learn

  • Intl.PluralRules
  • Intl.RelativeTimeFormat
  • Intl.Segmenter
  • locale data

How it works

Intl APIs provide locale-sensitive number, date, plural, relative-time, and text- segmentation behavior. Segmenting words by spaces fails for some writing systems; use Intl.Segmenter when supported and provide a deliberate fallback. Formatting is not translation: translated content is still needed.

Common mistake

String length and space splitting do not reliably count user-perceived characters or words across languages.

Guided challenge

Format a relative time and segment a Japanese sentence into words; show a fallback message if Segmenter is unavailable.

Further reading

Run the example

Open example.html, inspect example.js, then edit and refresh. For APIs that need an origin, run a local server from the JavaScripts folder.

Completion check

  • Explain the behavior and its limits in your own words.
  • Test a normal case and a failure or cleanup case.
  • Record when this feature is useful and when a simpler approach is better.