Internationalization & Localization

Intermediate · 39 min

How to build apps that adapt to any locale — formatting with Intl, externalizing strings for translation, and handling RTL layouts.

Before thisComponent-Based Architecture

Web Dev Simplified · 39 min

Internationalization & Localization

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Web Dev SimplifiedReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Internationalization (i18n) is the engineering work of making an app capable of supporting any locale; localization (l10n) is the actual work of adapting it to one specific locale.
  • Dates, numbers, and currency are not just formatting preferences — they differ structurally between locales, which is why the Intl API should format them instead of hand-built string logic.
  • Externalizing strings into translation catalogs keeps user-facing text out of the code, so a translator can work without touching logic, and the app can load a different language file per locale.
  • Right-to-left languages like Arabic and Hebrew require layout, not just text, to adapt, which is why logical CSS properties exist as the direction-aware alternative to physical ones.
  • i18n is a decision made early in an app's structure — retrofitting it after strings and layout are hardcoded for one language is far more expensive than designing for it from the start.

Two different jobs with similar-sounding names

Internationalization (i18n — 18 letters between the i and the n) is the engineering work of making your app capable of supporting any locale, structurally. Localization (l10n) is the actual act of adapting it to one specific locale — translating the strings into Japanese, formatting dates the way Germany does, mirroring the layout for Arabic. You do i18n once, as part of how the app is built. You do l10n repeatedly, once per locale you want to support. An app that was never internationalized can’t be localized without first going back and restructuring it, which is the whole reason this distinction matters practically and not just as vocabulary.

Formatting isn’t cosmetic — it’s structural

It’s tempting to think of date and number formatting as a cosmetic detail: swap the separator, done. It’s not that simple. The US writes dates as month/day/year; most of Europe writes day/month/year; Japan commonly writes year/month/day. Some locales use a comma as the decimal separator and a period for thousands — the exact reverse of US convention. Currency isn’t just a symbol choice either: the symbol’s position, whether a space separates it from the number, and how many decimal places are shown (Japanese yen typically has none) all vary.

This is exactly the kind of logic nobody should write by hand, because getting all of these variations right, for every locale you might ever support, is a losing battle. JavaScript’s built-in Intl API exists specifically for this:

new Intl.DateTimeFormat('de-DE').format(new Date()); // "14.11.2026"
new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(1234.5); // "$1,234.50"

Hand the value and a locale string to Intl, and the browser — which already has this data built in — produces a correctly formatted result. The lesson here isn’t memorizing Intl’s API surface; it’s recognizing that formatting dates, numbers, and currency is a solved problem you should never be solving yourself with string concatenation.

Getting text out of your components

The second structural piece of i18n is string externalization. If a button’s label is written directly into a component — <button>Submit</button> — supporting a second language means hunting through every component for every hardcoded string. Instead, externalized apps reference a key — t('submit_button') — and look that key up in a translation catalog, typically one JSON or YAML file per locale:

// en.json
{ "submit_button": "Submit" }
// fr.json
{ "submit_button": "Envoyer" }

This does two things. It lets a translator work entirely within these files, without touching component code or needing to understand the app’s logic. And it lets the app load a different catalog per locale at runtime, swapping every visible string in one move rather than needing a separate build per language.

Right-to-left: when layout itself has to flip

Formatting and translation handle text content, but languages like Arabic and Hebrew need something structurally different: the whole layout mirrors, because the reading direction itself is reversed. Setting dir="rtl" on the page (or a specific element) tells the browser to flow text and inline content right-to-left — but that alone doesn’t fix layout built with physical CSS properties.

If a sidebar uses margin-left: 16px to create space from the content next to it, that space stays on the left even when the whole page mirrors to RTL — which is now the wrong side. The fix is logical properties: margin-inline-start means “the start of the reading direction,” which is the left in English and the right in Arabic, automatically, with no per-locale CSS needed. The same idea applies to padding-inline-end, inset-inline-start, and more — anywhere a design currently says “left” or “right,” it’s worth asking whether it actually means “start” or “end” instead. Icons that imply direction (like a “back” arrow) also often need an explicit flip in RTL, since mirroring the layout doesn’t automatically know an icon’s meaning is directional.

Why this has to be decided early

All three pieces — formatting, externalized strings, and logical layout — share one property: they’re far cheaper to build in from the start than to retrofit. An app with hundreds of hardcoded strings, hand-rolled date formatting, and a stylesheet full of margin-left isn’t impossible to internationalize later, but it means re-touching nearly every component. Treating i18n as a structural decision made early — even if you only ever ship one language at launch — is what keeps the door open for the day a second locale is actually required.

Check yourself

  1. 01What's the practical difference between internationalization and localization?

    Internationalization is the engineering groundwork that makes an app capable of being adapted to any locale — externalized strings, locale-aware formatting, flexible layout. Localization is the actual act of adapting the app to one specific locale, like translating its strings into French or formatting its dates the way Japan does.

  2. 02Why is hand-building date or currency formatting logic risky, and what should you use instead?

    Date formats, number separators, and currency symbols all vary by locale in ways that are easy to get subtly wrong by hand — not just symbols, but ordering, decimal versus thousands separators, and which currency goes where. The `Intl` API, built into JavaScript, handles this correctly for a given locale by asking the browser to format the value rather than constructing the string yourself.

  3. 03Why can't you just flip `direction: rtl` on the page and call right-to-left support done?

    Flipping direction reverses text flow, but layout built with physical properties like `margin-left` or `padding-right` doesn't automatically mirror with it, so spacing and alignment end up wrong in an RTL context. Logical CSS properties like `margin-inline-start`, which mean "the start of the reading direction" rather than a fixed physical side, adapt automatically and are the reliable way to support both directions from the same stylesheet.

  4. 04Why is it cheaper to plan for internationalization early rather than adding it after launch?

    Once user-facing strings are written directly into components, dates are formatted with hardcoded logic, and layout assumes left-to-right text, every one of those decisions has to be found and unwound individually to support a new locale. Designing for externalized strings, Intl-based formatting, and logical CSS from the start means adding a new locale later is mostly a matter of adding a translation file, not restructuring the app.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark