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-US

Date: MM/DD/YYYY

Number: 1,234.56

Currency: $1,234.56

English (Canada)

en-CA

Date: YYYY-MM-DD

Number: 1,234.56

Currency: CA$1,234.56

French (Canada)

fr-CA

Date: YYYY-MM-DD

Number: 1 234,56

Currency: 1 234,56 $

Spanish (Mexico)

es-MX

Date: DD/MM/YYYY

Number: 1,234.56

Currency: $1,234.56

English (United Kingdom)

en-GB

Date: DD/MM/YYYY

Number: 1,234.56

Currency: £1,234.56

French (France)

fr-FR

Date: DD/MM/YYYY

Number: 1 234,56

Currency: 1 234,56 €

German (Germany)

de-DE

Date: DD.MM.YYYY

Number: 1.234,56

Currency: 1.234,56 €

Italian (Italy)

it-IT

Date: DD/MM/YYYY

Number: 1.234,56

Currency: 1.234,56 €

Spanish (Spain)

es-ES

Date: DD/MM/YYYY

Number: 1.234,56

Currency: 1.234,56 €

Portuguese (Portugal)

pt-PT

Date: DD/MM/YYYY

Number: 1 234,56

Currency: 1 234,56 €

Dutch (Netherlands)

nl-NL

Date: DD-MM-YYYY

Number: 1.234,56

Currency: € 1.234,56

Swedish (Sweden)

sv-SE

Date: YYYY-MM-DD

Number: 1 234,56

Currency: 1 234,56 kr

Polish (Poland)

pl-PL

Date: DD.MM.YYYY

Number: 1 234,56

Currency: 1 234,56 zł

Russian (Russia)

ru-RU

Date: DD.MM.YYYY

Number: 1 234,56

Currency: 1 234,56 ₽

Japanese (Japan)

ja-JP

Date: YYYY/MM/DD

Number: 1,234.56

Currency: ¥1,234

Chinese (Simplified)

zh-CN

Date: YYYY-MM-DD

Number: 1,234.56

Currency: ¥1,234.56

Chinese (Traditional)

zh-TW

Date: YYYY/MM/DD

Number: 1,234.56

Currency: NT$1,234.56

Korean (South Korea)

ko-KR

Date: YYYY. MM. DD

Number: 1,234.56

Currency: ₩1,234.56

Thai (Thailand)

th-TH

Date: DD/MM/YYYY

Number: 1,234.56

Currency: ฿1,234.56

Vietnamese (Vietnam)

vi-VN

Date: DD/MM/YYYY

Number: 1.234,56

Currency: 1.234,56 ₫

Hindi (India)

hi-IN

Date: DD/MM/YYYY

Number: 1,234.56

Currency: ₹1,234.56

Arabic (Saudi Arabia)

ar-SA

Date: DD/MM/YYYY

Number: 1,234.56

Currency: 1,234.56 ر.س.

Arabic (UAE)

ar-AE

Date: DD/MM/YYYY

Number: 1,234.56

Currency: 1,234.56 د.إ

Hebrew (Israel)

he-IL

Date: DD/MM/YYYY

Number: 1,234.56

Currency: ₪1,234.56

Portuguese (Brazil)

pt-BR

Date: DD/MM/YYYY

Number: 1.234,56

Currency: R$1.234,56

Spanish (Argentina)

es-AR

Date: DD/MM/YYYY

Number: 1.234,56

Currency: $1.234,56

Spanish (Chile)

es-CL

Date: DD-MM-YYYY

Number: 1.234,56

Currency: CLP$1.234

English (Australia)

en-AU

Date: DD/MM/YYYY

Number: 1,234.56

Currency: A$1,234.56

English (New Zealand)

en-NZ

Date: 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