Skip to content
Web Design & Development

Internationalization with the Intl API, Done Properly

Formatting numbers, currencies, dates, lists and plural forms correctly for each language and region using JavaScript's built-in Intl API.

MediaScaleUp Editorial Team 2 min read 11 views
Internationalization with the Intl API, Done Properly

What is at stake

Hand-written formatting breaks as soon as a site serves more than one locale, while the Intl API handles regional conventions built into the browser.

The playbook

  1. Format all numbers and prices with Intl.NumberFormat
  2. Use PluralRules instead of adding s
  3. Pass explicit locales from user settings
  4. Keep currency codes with prices
  5. Test with locales that use different separators

Where it goes wrong

Avoid:

  • Concatenating strings with numbers
  • Hard-coded currency symbols
  • English plural logic in other languages
  • Assuming the browser locale is the user's preference
What to do and what to avoid with internationalization with the intl API, side by side
Good practice against the usual mistakes, from the sources listed below.

The numbers behind it

Published figures for Internationalization with the Intl API
MeasureFigure
StandardECMA-402, the ECMAScript Internationalization API
NumberFormatformats numbers and currencies for a locale
PluralRulesselects the right plural category for a language
Locale identifiersBCP 47 tags such as en-US and fr-CA

Getting outside help

When to hand it over: Bring in help when launching in new countries or languages, or when prices and dates display inconsistently.

Where this comes from

The figures and practices above come from the sources listed.

Working on something like this?

We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.

Where to go next

Spotted something wrong? Report an error on this page. We correct on the page and say what changed.

All services

The work behind this article, and what it costs.

MediaScaleUp Editorial Team

Articles here are researched, written and checked by the MediaScaleUp studio team before they are published, and dated when they are reviewed.

Keep reading

More in Web Design & Development