Course contentsShow
← JavaScript
Lesson 2241 of 2,72346. InternationalizationFree lesson

Intl.DisplayNames: Getting Localized Names for Codes

Discover how DisplayNames translates language/region/currency codes into readable names.

Intl.DisplayNames: Getting Localized Names for Codes

You'll learn how to translate cryptic codes like "en-US" or "EUR" into human-readable, localized names.

What's the Problem?

You often work with standardized codes—language tags ("fr"), region codes ("JP"), currency codes ("GBP"), or script identifiers ("Latn"). While these codes are machine-friendly, they're not great for users. Showing "en-US" instead of "American English" or "USD" instead of "US Dollar" creates a poor experience.

How Intl.DisplayNames Helps

Intl.DisplayNames acts like a localized dictionary that translates codes into readable names based on the user's locale. Think of it as turning abbreviations into full words—but doing so in the user's own language.

You create an instance specifying:

  • A locale (e.g., "en", "de", "ja")
  • A type (what kind of code: "language", "region", "currency", "script")

Then call .of(code) to get the localized name.

The Core Pattern

const regionNames = new Intl.DisplayNames(['en'], { type: 'region' });
console.log(regionNames.of('US')); // "United States"
console.log(regionNames.of('JP')); // "Japan"

const langNames = new Intl.DisplayNames(['fr'], { type: 'language' });
console.log(langNames.of('en')); // "anglais"
console.log(langNames.of('fr')); // "français"

const currencyNames = new Intl.DisplayNames(['de'], { type: 'currency' });
console.log(currencyNames.of('EUR')); // "Euro"
console.log(currencyNames.of('USD')); // "US-Dollar"

Notice how the same code yields different names depending on the locale you choose.

Key Takeaway: Intl.DisplayNames transforms language, region, currency, and script codes into localized, user-friendly names—perfect for dropdowns, labels, or any UI element where human readability matters.