Mrs. Sri owns Mist Homestay, a small homestay in the mountains. She wants to start taking guests from abroad: guests from Indonesia, guests from Japan, guests from Egypt. Her booking page is all in American English, including "Dec 12, 2026, 2:00 PM" and "2 nights". Translating the words is not enough. There are two different jobs, and Mrs. Sri's rooms can show both.
The first job is installing universal sockets in every room. It is done once, while building, and after that a plug from any country fits. In an app, this job is called internationalization, shortened to i18n. It means preparing the code so the app can be used in any language and with any region's conventions (how a region writes dates, prices and so on) without changing the code. The app's code is the wall and the sockets of that room.
The second job is putting a guidebook in Japanese in the room for a guest from Japan, with prices and times written the way people write them in Japan. It is done per guest, and no wall is broken open. In an app, this job is called localization, shortened to l10n. It means preparing the content for one language and region, from the translation to the price format and the date format. The guest is one language and region, and the guidebook is that translation and those formats.
i18n, l10n, g11n and translation
These four terms are often confused. The number in the middle of each short form is only a count of the letters that were skipped. Take i18n: the letter i, then 18 letters, then the letter n, from the word internationalization. In the same way, l10n (l, 10 letters, n) comes from localization, and g11n (g, 11 letters, n) comes from globalization.
| Term | What it means | On Mrs. Sri's page |
|---|---|---|
| Translation | Replacing words with words of another language | "Book now" becomes "予約する" |
| l10n (localization) | Adjusting the page for one locale (one language and region): the translation, plus the formats for money, dates and counts, and the writing direction | For a guest from Japan: price $70, date 12月12日, "2泊" |
| i18n (internationalization) | Preparing the code's architecture (how the code is organised) so l10n can be done without changing the code | Text moves into one dictionary per language (a list of texts and their translations), numbers and dates go through Intl (JavaScript's built-in formatting tool), files are saved as UTF-8 (a way to store the letters of every language), CSS uses logical properties (properties that follow the writing direction) |
| g11n (globalization) | The decision and the work to serve another market, i18n and l10n included | Mrs. Sri decides to take guests from Japan and Egypt, including how they pay and when she answers chats |
- Developers do i18n, once, in the code's architecture. l10n is done per language, often by translators. It can be repeated for a new language without a developer touching the code.
- Translation is only part of l10n. If the words on a page are already Japanese but the page still says "Dec 12, 2026" and "2 nights", its l10n is not finished.
- The UI/UX lesson "Internationalization (i18n)" already formatted Mrs. Sri's booking card with
Intl.NumberFormat,Intl.DateTimeFormatandIntl.PluralRules. This track continues from there.
Locale: a code for language, script and region
A locale is a code that names a language and the regional conventions in use, such as en-US for English in the United States. On the web, a locale is written in BCP 47 format, also called a language tag: a few parts joined by hyphens. It has three main parts: language, script (the writing system, such as Latin or Cyrillic letters) and region.
| Tag | Language | Script | Region | Used for |
|---|---|---|---|---|
en-US |
en English |
US United States |
Mrs. Sri's original page | |
ja-JP |
ja Japanese |
JP Japan |
Guests from Japan | |
zh-Hant-TW |
zh Chinese |
Hant Traditional Han |
TW Taiwan |
A tag with three parts |
sr-Latn |
sr Serbian |
Latn Latin |
Serbian written in Latin letters | |
es-419 |
es Spanish |
419 Latin America |
A region can be a number code |
- Language: 2 or 3 lowercase letters (listed in the standard ISO 639). Script: 4 letters, the first one a capital (ISO 15924). Region: 2 capital letters (ISO 3166) or 3 digits.
- Script and region are optional.
Intl.Localecan fill in the missing parts with the most common choice. In the code below, the comment on the right is the result:
new Intl.Locale('ja').maximize().toString(); // "ja-Jpan-JP"
new Intl.Locale('ar').maximize().toString(); // "ar-Arab-EG"
new Intl.Locale('sr').maximize().toString(); // "sr-Cyrl-RS": without Latn, Serbian is written in Cyrillic
new Intl.Locale('zh-TW').maximize().toString(); // "zh-Hant-TW"
Intl.getCanonicalLocales('EN-us'); // ["en-US"]: upper and lower case tidied up
The results are the same in Chromium 147 (Chrome's engine), Firefox 146, WebKit 26.4 (Safari's engine) and Node 22.22.1.
maximize()adds the most likely script and region.minimize()does the opposite: it removes the parts that can be guessed. For example,new Intl.Locale('en-US').minimize().toString()gives"en".- The separator must be a hyphen.
en_USwith an underscore (the style of Java, PHP'ssetlocaleand Linux) is not BCP 47. That is whynew Intl.NumberFormat('en_US')throws aRangeError: the code stops with an error. The message is "Invalid language tag: en_US" in Chrome,invalid language tag: "en_US"in Firefox and "invalid language tag: en_US" in Safari.
Four locales for Mist Homestay
This track takes Mrs. Sri's page into four locales. Each locale was chosen because it tests something different:
en-US, the source language. Mrs. Sri writes all the text in English first, and then that text is translated. Its plurals (how a word changes with the count) have two forms: 1 night, 2 nights.id-ID, for guests from Indonesia. Indonesian has no plural forms: 1 malam, 2 malam ("malam" is "night").ja-JP, for guests from Japan who come to watch the sunrise from the mountain top. Its script belongs to CJK (Chinese, Japanese, Korean). Japanese is written with no spaces between words and has no plural forms (2泊). Almost every character takes 3 bytes in UTF-8.ar-EG, for guests from Egypt. Arabic is written from right to left (RTL). Its digits are Eastern Arabic digits (٧٠٠٬٠٠٠). Its plurals have six categories: zero, one, two, few, many, other.
Why ar-EG (Egypt) and not ar-SA (Saudi Arabia)? Because the region changes the formatted result. For ar-SA, Safari 26.4 uses the Hijri (Islamic) calendar and writes 12 December 2026 as ٣ رجب ١٤٤٨ هـ. Chrome and Firefox use the Gregorian calendar (the one most countries use) for the same locale. For ar-EG, all three browsers use the Gregorian calendar.
The table below shows the same card in four locales, formatted by Intl in Chromium 147. The settings: prices with no decimals (maximumFractionDigits: 0), dates and times with dateStyle: 'medium' and timeStyle: 'short', and the homestay's time zone (timeZone: 'Asia/Singapore').
en-US |
id-ID |
ja-JP |
ar-EG |
|
|---|---|---|---|---|
| Total for 2 nights | $70 | US$70 | $70 | ٧٠ US$ |
| Check-in | Dec 12, 2026, 2:00 PM | 12 Des 2026, 14.00 | 2026/12/12 14:00 | ١٢/١٢/٢٠٢٦، ٢:٠٠ م |
| Plural category for 2 | other | other | other | two |
| The 2-night button | 2 nights | 2 malam | 2泊 | ليلتان |
| Writing direction | left to right | left to right | left to right | right to left |
The word on the 2-night button comes from the translation dictionary. Intl.PluralRules only says which plural category applies to a number. The dictionary holds the word for each category. Arabic has its own form for exactly two (the dual): ليلتان means "two nights". That is why the category for 2 in ar-EG is two, not other.
What changes besides the words
| Aspect | Example on Mrs. Sri's page |
|---|---|
| Numbers and money | A comma as the thousands separator in en-US and ja-JP, a dot in id-ID, and ٬ with the digits ٠ to ٩ in ar-EG. "$" before the number in en-US, "US$" after it in ar-EG. |
| Dates and times | "Saturday, December 12, 2026 at 2:00 PM" in en-US, "Sabtu, 12 Desember 2026 pukul 14.00" in id-ID, "2026年12月12日土曜日 14:00" in ja-JP. |
| Counts | 2 nights, 2 malam, 2泊, ليلتان: the word's form follows the count. |
| Direction | Arabic is written right to left, so the green stripe on the left edge of the card has to move to the right. |
| Alphabetical order | ['Zahra', 'Ömer', 'andi'].sort() gives ["Zahra", "andi", "Ömer"]. That order follows the letters' codes, not any language's alphabet: capitals first, then lowercase letters, then Ö. Each language has its own order: Swedish puts Ö after Z, German puts it with O. |
| People's names | Many Indonesians have a one-word name, and Japanese names are written family name first (山田 太郎). Required "First name" plus "Last name" fields are a problem for both. |
| Addresses | Japanese addresses go from the largest area to the smallest and start with the postal mark 〒 and the postal code; Indonesian addresses have RT/RW and kelurahan, the names of small local areas. |
| Text length | "Book now, pay at the homestay" and its Indonesian translation "Pesan kamar, bayar di tempat" differ in width, as measured in the UI/UX lesson. |
Counting the hard-coded text on Mrs. Sri's page
Hard-coded means the text is written directly in the code and does not come from a dictionary. This is the code of Mrs. Sri's booking card before any i18n work:
<html lang="en">
<head>
<title>Terrace Room · Mist Homestay</title>
<style>.card { padding-left: 20px; border-left: 4px solid #15803d; }</style>
</head>
<body>
<section class="card">
<h1>Terrace Room</h1>
<p>$35 / night</p>
<p>Check-in Dec 12, 2026, 2:00 PM</p>
<div role="group" aria-label="Length of stay">
<button>1 night</button>
<button aria-pressed="true">2 nights</button>
<button>3 nights</button>
</div>
<p id="total">Total for 2 nights: $70</p>
<button>Book now, pay at the homestay</button>
<p>Free cancellation up to 3 days before check-in.</p>
</section>
<script>
function pick(n) {
document.getElementById('total').textContent =
'Total for ' + n + ' nights: $' + (35 * n).toLocaleString('en-US');
}
</script>
</body>
</html>
In that code there are 11 texts that a guest reads or hears:
| Kind | Texts | Count |
|---|---|---|
| Words only | <title>, the heading "Terrace Room", the aria-label "Length of stay", the button "Book now, pay at the homestay" |
4 |
| Words plus a number, money, a date or a count | "$35 / night", "Check-in Dec 12, 2026, 2:00 PM", "1 night", "2 nights", "3 nights", "Total for 2 nights: $70", "Free cancellation up to 3 days before check-in." | 7 |
Only 4 of those 11 texts can be translated word for word. The other seven need Intl or plural rules, because their numbers, dates and word forms change per locale. There are 3 more places in the code that must change too, outside those 11 texts:
lang="en"on<html>, which tells the browser the language of the page. Its value has to follow the locale.- The script that joins the pieces
'Total for ' + n + ' nights: $'and always formats the number withtoLocaleString('en-US'). Sentence pieces like these can't be translated one by one, because every language builds the sentence in its own way: Indonesian needs "Total 2 malam", Arabic needs the dual form. - The CSS
padding-leftandborder-left, which stay on the left although forar-EGthey must move to the right.
The two texts people forget most often are <title> and aria-label. Neither shows on the card. <title> appears in the browser tab, and a screen reader (a program that reads the page aloud for blind users) reads aria-label.
⚠️ What gets missed when you start with i18n
- Treating i18n as translation. If the words are Japanese but the date still says "Dec 12, 2026" and the count still says "2 nights", the work is only half done.
- Writing the locale with an underscore.
en_USthrows aRangeErrorinIntl. Useen-US. - Forgetting the text nobody sees.
<title>,aria-label,alt,placeholderand error messages are hard-coded text too. - A locale without a region for formatting.
aruses the digits 0 to 9,ar-EGuses ٠ to ٩, andar-SAin Safari uses the Hijri calendar. For formatting, write the full locale with its region, then check in more than one browser.
TL;DR: i18n (i, 18 letters, n: internationalization) prepares the code's architecture (how the code is organised) so the app can work in many languages without the code changing. l10n (localization) prepares the content for one locale, which is one language and region: the translation plus the formats for money and dates, plural forms (1 night, 2 nights), and the writing direction. Translation is only part of l10n, and g11n (globalization) is the decision to serve another market. A locale is written in BCP 47 format with hyphens: language, script (the writing system), region (en-US, zh-Hant-TW, sr-Latn). en_US with an underscore throws a RangeError. This track uses en-US (the source language), id-ID, ja-JP (no plural forms, CJK script: Chinese, Japanese, Korean) and ar-EG (RTL: right to left, digits ٠ to ٩, six plural categories). Not only the words change: numbers, money, dates, plurals, direction, alphabetical order, names, addresses. Mrs. Sri's booking card has 11 hard-coded texts (written directly in the code), and only 4 can be translated word for word. The lang attribute, the sentence pieces joined in the script, and the CSS that says left or right must change too.
⚡ i18n: i, 18 letters, n
Guess first: i18n is short for internationalization. What does the 18 in that short form count?
The letters between the i and the n of internationalization. The short form l10n is made the same way: l, 10 letters, n for localization.
Meaning: i18n is the job of preparing the code, once, so the app can be used in any language and with any region's conventions (how a region writes dates, prices and so on) without changing the code. l10n is the job of preparing the content for one locale (one language and region, such as Japanese in Japan): the translation plus the formats for money and dates, plural forms (1 night, 2 nights), and the writing direction.
⚡ A locale is written with hyphens
Write:
new Intl.Locale('ja').maximize().toString(); // "ja-Jpan-JP"
Intl.getCanonicalLocales('EN-us'); // ["en-US"]: upper and lower case tidied up
Guess first: Intl is JavaScript's built-in formatting tool, and a locale must be written with a hyphen, like en-US. What happens if you write new Intl.NumberFormat('en_US'), with an underscore?
The code throws a RangeError: it stops with an error. en_US is the style of Java, PHP's setlocale and Linux, not BCP 47, the locale format of the web.
Meaning: A locale is written in BCP 47 format: language, script (the writing system, such as Latin), then region, joined by hyphens (en-US, zh-Hant-TW, sr-Latn). Script and region are optional. On the first line of the code, maximize() fills in those two parts with the most common choice. The second line fixes the upper and lower case.
⚡ More than words
Meaning: The example in this track is the room booking card on the web page of Mrs. Sri, who owns a homestay. The card has 11 hard-coded texts (written directly in the code), and only 4 can be translated word for word. The other seven hold a number, money, a date or a count, such as "2 nights". Those seven need Intl or plural rules, because their numbers, dates and word forms change per locale. Three more places must change too: the lang attribute, the sentence pieces joined in the script, and the CSS that says left or right.