| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since April 2021.
The Intl.DisplayNames object enables the consistent translation of language, region and script display names.
const regionNamesInEnglish = new Intl.DisplayNames(["en"], { type: "region" });
const regionNamesInTraditionalChinese = new Intl.DisplayNames(["zh-Hant"], {
type: "region",
});
console.log(regionNamesInEnglish.of("US"));
// Expected output: "United States"
console.log(regionNamesInTraditionalChinese.of("US"));
// Expected output: ""
Intl.DisplayNames()Creates a new Intl.DisplayNames object.
Intl.DisplayNames.supportedLocalesOf()Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.
These properties are defined on Intl.DisplayNames.prototype and shared by all Intl.DisplayNames instances.
Intl.DisplayNames.prototype.constructorThe constructor function that created the instance object. For Intl.DisplayNames instances, the initial value is the Intl.DisplayNames constructor.
Intl.DisplayNames.prototype[Symbol.toStringTag]The initial value of the [Symbol.toStringTag] property is the string "Intl.DisplayNames". This property is used in Object.prototype.toString().
Intl.DisplayNames.prototype.of()This method receives a code and returns a string based on the locale and options provided when instantiating Intl.DisplayNames.
Intl.DisplayNames.prototype.resolvedOptions()Returns a new object with properties reflecting the locale and formatting options computed during initialization of the object.
To create an Intl.DisplayNames for a locale and get the display name for a region code.
// Get display names of region in English
let regionNames = new Intl.DisplayNames(["en"], { type: "region" });
regionNames.of("419"); // "Latin America"
regionNames.of("BZ"); // "Belize"
regionNames.of("US"); // "United States"
regionNames.of("BA"); // "Bosnia & Herzegovina"
regionNames.of("MM"); // "Myanmar (Burma)"
// Get display names of region in Traditional Chinese
regionNames = new Intl.DisplayNames(["zh-Hant"], { type: "region" });
regionNames.of("419"); // ""
regionNames.of("BZ"); // ""
regionNames.of("US"); // ""
regionNames.of("BA"); // ""
regionNames.of("MM"); // ""
To create an Intl.DisplayNames for a locale and get the display name for a language-script-region sequence.
// Get display names of language in English
let languageNames = new Intl.DisplayNames(["en"], { type: "language" });
languageNames.of("fr"); // "French"
languageNames.of("de"); // "German"
languageNames.of("fr-CA"); // "Canadian French"
languageNames.of("zh-Hant"); // "Traditional Chinese"
languageNames.of("en-US"); // "American English"
languageNames.of("zh-TW"); // "Chinese (Taiwan)"]
// Get display names of language in Traditional Chinese
languageNames = new Intl.DisplayNames(["zh-Hant"], { type: "language" });
languageNames.of("fr"); // ""
languageNames.of("zh"); // ""
languageNames.of("de"); // ""
To create an Intl.DisplayNames for a locale and get the display name for a script code.
// Get display names of script in English
let scriptNames = new Intl.DisplayNames(["en"], { type: "script" });
// Get script names
scriptNames.of("Latn"); // "Latin"
scriptNames.of("Arab"); // "Arabic"
scriptNames.of("Kana"); // "Katakana"
// Get display names of script in Traditional Chinese
scriptNames = new Intl.DisplayNames(["zh-Hant"], { type: "script" });
scriptNames.of("Latn"); // ""
scriptNames.of("Arab"); // ""
scriptNames.of("Kana"); // ""
To create an Intl.DisplayNames for a locale and get the display name for currency code.
// Get display names of currency code in English
let currencyNames = new Intl.DisplayNames(["en"], { type: "currency" });
// Get currency names
currencyNames.of("USD"); // "US Dollar"
currencyNames.of("EUR"); // "Euro"
currencyNames.of("TWD"); // "New Taiwan Dollar"
currencyNames.of("CNY"); // "Chinese Yuan"
// Get display names of currency code in Traditional Chinese
currencyNames = new Intl.DisplayNames(["zh-Hant"], { type: "currency" });
currencyNames.of("USD"); // ""
currencyNames.of("EUR"); // ""
currencyNames.of("TWD"); // ""
currencyNames.of("CNY"); // ""
| Specification |
|---|
| ECMAScript 2027 Internationalization API Specification # intl-displaynames-objects |
This page was last modified on Jul 10, 2025 by MDN contributors.
Intl.DisplayNamesObject/FunctionIntlIntl.CollatorIntl.DateTimeFormatIntl.DurationFormatIntl.ListFormatIntl.LocaleIntl.NumberFormatIntl.PluralRulesIntl.RelativeTimeFormatIntl.SegmenterYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |