I18N Resources & Code Snippets
Explore internationalization (i18n) resources, locale examples, and code snippets. Learn how to implement proper localization in your applications.
Locale Examples
English (United States)
en-USDate: MM/DD/YYYY
Number: 1,234.56
Currency: $1,234.56
English (Canada)
en-CADate: YYYY-MM-DD
Number: 1,234.56
Currency: CA$1,234.56
French (Canada)
fr-CADate: YYYY-MM-DD
Number: 1 234,56
Currency: 1 234,56 $
Spanish (Mexico)
es-MXDate: DD/MM/YYYY
Number: 1,234.56
Currency: $1,234.56
English (United Kingdom)
en-GBDate: DD/MM/YYYY
Number: 1,234.56
Currency: £1,234.56
French (France)
fr-FRDate: DD/MM/YYYY
Number: 1 234,56
Currency: 1 234,56 €
German (Germany)
de-DEDate: DD.MM.YYYY
Number: 1.234,56
Currency: 1.234,56 €
Italian (Italy)
it-ITDate: DD/MM/YYYY
Number: 1.234,56
Currency: 1.234,56 €
Spanish (Spain)
es-ESDate: DD/MM/YYYY
Number: 1.234,56
Currency: 1.234,56 €
Portuguese (Portugal)
pt-PTDate: DD/MM/YYYY
Number: 1 234,56
Currency: 1 234,56 €
Dutch (Netherlands)
nl-NLDate: DD-MM-YYYY
Number: 1.234,56
Currency: € 1.234,56
Swedish (Sweden)
sv-SEDate: YYYY-MM-DD
Number: 1 234,56
Currency: 1 234,56 kr
Polish (Poland)
pl-PLDate: DD.MM.YYYY
Number: 1 234,56
Currency: 1 234,56 zł
Russian (Russia)
ru-RUDate: DD.MM.YYYY
Number: 1 234,56
Currency: 1 234,56 ₽
Japanese (Japan)
ja-JPDate: YYYY/MM/DD
Number: 1,234.56
Currency: ¥1,234
Chinese (Simplified)
zh-CNDate: YYYY-MM-DD
Number: 1,234.56
Currency: ¥1,234.56
Chinese (Traditional)
zh-TWDate: YYYY/MM/DD
Number: 1,234.56
Currency: NT$1,234.56
Korean (South Korea)
ko-KRDate: YYYY. MM. DD
Number: 1,234.56
Currency: ₩1,234.56
Thai (Thailand)
th-THDate: DD/MM/YYYY
Number: 1,234.56
Currency: ฿1,234.56
Vietnamese (Vietnam)
vi-VNDate: DD/MM/YYYY
Number: 1.234,56
Currency: 1.234,56 ₫
Hindi (India)
hi-INDate: DD/MM/YYYY
Number: 1,234.56
Currency: ₹1,234.56
Arabic (Saudi Arabia)
ar-SADate: DD/MM/YYYY
Number: 1,234.56
Currency: 1,234.56 ر.س.
Arabic (UAE)
ar-AEDate: DD/MM/YYYY
Number: 1,234.56
Currency: 1,234.56 د.إ
Hebrew (Israel)
he-ILDate: DD/MM/YYYY
Number: 1,234.56
Currency: ₪1,234.56
Portuguese (Brazil)
pt-BRDate: DD/MM/YYYY
Number: 1.234,56
Currency: R$1.234,56
Spanish (Argentina)
es-ARDate: DD/MM/YYYY
Number: 1.234,56
Currency: $1.234,56
Spanish (Chile)
es-CLDate: DD-MM-YYYY
Number: 1.234,56
Currency: CLP$1.234
English (Australia)
en-AUDate: DD/MM/YYYY
Number: 1,234.56
Currency: A$1,234.56
English (New Zealand)
en-NZDate: DD/MM/YYYY
Number: 1,234.56
Currency: NZ$1,234.56
Code Snippets for English (United States)
Date Formatting (US)
Format dates according to US locale conventions
// Using Intl.DateTimeFormat
const date = new Date();
const formatter = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
console.log(formatter.format(date)); // e.g., "March 15, 2024"Number Formatting (US)
Format numbers with US locale-specific separators
// Using Intl.NumberFormat
const number = 1234567.89;
const formatter = new Intl.NumberFormat('en-US');
console.log(formatter.format(number)); // "1,234,567.89"Currency Formatting (US)
Format currency values according to US locale
// Using Intl.NumberFormat for the United States (en-US)
const amount = 1234.56;
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
});
console.log(formatter.format(amount)); // "$1,234.56"Pluralization (United States)
Handle plural forms correctly in United States (English)
// Using Intl.PluralRules for United States (en-US)
const rules = new Intl.PluralRules('en-US');
const forms = {
one: 'item',
other: 'items'
};
const count = 3;
console.log(`${count} ${forms[rules.select(count)]}`); // "3 items"Best Practices
- Always use Unicode for character encoding
- Store dates in UTC and convert to local time for display
- Use locale-aware functions for formatting
- Support right-to-left (RTL) languages
- Implement proper pluralization rules
- Use ISO language and country codes
- Consider cultural differences in colors and symbols
Common Pitfalls
- Hardcoding date and number formats
- Assuming all languages use the same plural rules
- Not considering text expansion in translations
- Concatenating translated strings
- Using flags to represent languages
- Ignoring cultural preferences