Intl.DisplayNames
BaselineWidely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
TheIntl.DisplayNames
object enables the consistent translation of language, region and script display names.
Try it
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: "美國"
Constructor
Intl.DisplayNames()
Creates a new
Intl.DisplayNames
object.
Static methods
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.
Instance properties
These properties are defined onIntl.DisplayNames.prototype
and shared by allIntl.DisplayNames
instances.
Intl.DisplayNames.prototype.constructor
The constructor function that created the instance object. For
Intl.DisplayNames
instances, the initial value is theIntl.DisplayNames
constructor.Intl.DisplayNames.prototype[Symbol.toStringTag]
The initial value of the
[Symbol.toStringTag]
property is the string"Intl.DisplayNames"
. This property is used inObject.prototype.toString()
.
Instance methods
Intl.DisplayNames.prototype.of()
This method receives a
code
and returns a string based on the locale and options provided when instantiatingIntl.DisplayNames
.Intl.DisplayNames.prototype.resolvedOptions()
Returns a new object with properties reflecting the locale and formatting options computed during initialization of the object.
Examples
Region Code Display Names
To create anIntl.DisplayNames
for a locale and get the display name for a region code.
// Get display names of region in Englishlet 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 ChineseregionNames = new Intl.DisplayNames(["zh-Hant"], { type: "region" });regionNames.of("419"); // "拉丁美洲"regionNames.of("BZ"); // "貝里斯"regionNames.of("US"); // "美國"regionNames.of("BA"); // "波士尼亞與赫塞哥維納"regionNames.of("MM"); // "緬甸"
Language Display Names
To create anIntl.DisplayNames
for a locale and get the display name for a language-script-region sequence.
// Get display names of language in Englishlet 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 ChineselanguageNames = new Intl.DisplayNames(["zh-Hant"], { type: "language" });languageNames.of("fr"); // "法文"languageNames.of("zh"); // "中文"languageNames.of("de"); // "德文"
Script Code Display Names
To create anIntl.DisplayNames
for a locale and get the display name for a script code.
// Get display names of script in Englishlet scriptNames = new Intl.DisplayNames(["en"], { type: "script" });// Get script namesscriptNames.of("Latn"); // "Latin"scriptNames.of("Arab"); // "Arabic"scriptNames.of("Kana"); // "Katakana"// Get display names of script in Traditional ChinesescriptNames = new Intl.DisplayNames(["zh-Hant"], { type: "script" });scriptNames.of("Latn"); // "拉丁文"scriptNames.of("Arab"); // "阿拉伯文"scriptNames.of("Kana"); // "片假名"
Currency Code Display Names
To create anIntl.DisplayNames
for a locale and get the display name for currency code.
// Get display names of currency code in Englishlet currencyNames = new Intl.DisplayNames(["en"], { type: "currency" });// Get currency namescurrencyNames.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 ChinesecurrencyNames = new Intl.DisplayNames(["zh-Hant"], { type: "currency" });currencyNames.of("USD"); // "美元"currencyNames.of("EUR"); // "歐元"currencyNames.of("TWD"); // "新台幣"currencyNames.of("CNY"); // "人民幣"
Specifications
Specification |
---|
ECMAScript® 2026 Internationalization API Specification # intl-displaynames-objects |