Intl.DisplayNames
Creates an Intl.DisplayNames object that enables the consistent translation of language, region, and script display names
Syntax
new Intl.DisplayNames(locales, options)Parameters
| Parameter | Type | Description |
|---|---|---|
| locales | string | string[] | A BCP 47 language tag or array of tags |
| options | Intl.DisplayNamesOptions | Options: type (language, region, script, currency, calendar, dateTimeField) |
Return Value
An Intl.DisplayNames object with an of() method
Examples
const dn = new Intl.DisplayNames('en', { type: 'region' })
console.log(dn.of('US')) // 'United States'
console.log(dn.of('JP')) // 'Japan'const dn = new Intl.DisplayNames('en', { type: 'language' })
console.log(dn.of('fr')) // 'French'
console.log(dn.of('zh-Hans')) // 'Simplified Chinese'const dn = new Intl.DisplayNames('en', { type: 'currency' })
console.log(dn.of('USD')) // 'US Dollar'
console.log(dn.of('EUR')) // 'Euro'
console.log(dn.of('JPY')) // 'Japanese Yen'Understanding Intl.DisplayNames
The Intl.DisplayNames method in JavaScript creates an Intl.DisplayNames object that enables the consistent translation of language, region, and script display names. It belongs to the Intl object and is one of the most widely used methods for working with intl values in modern JavaScript and TypeScript applications.
The method signature is new Intl.DisplayNames(locales, options). It accepts 2 parameters: locales, options. When called, it returns an intl.displaynames object with an of() method. Understanding when and how to use DisplayNames() helps you write more expressive, readable code.
Common use cases for Intl.DisplayNames include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like intl-numberformat, intl-datetimeformat, intl-listformat, enabling you to chain operations together for complex data manipulation pipelines.
Supported in Chrome 81+, Firefox 86+, Safari 14.1+, Edge 81+.
Browser Compatibility
Supported in Chrome 81+, Firefox 86+, Safari 14.1+, Edge 81+.
Related Methods
Intl.NumberFormatCreates an Intl.NumberFormat object that enables language-sensitive number formatting
Intl.DateTimeFormatCreates an Intl.DateTimeFormat object that enables language-sensitive date and time formatting
Intl.ListFormatCreates an Intl.ListFormat object that enables language-sensitive list formatting
More Intl Methods
Other methods in the Intl object
Related Tools
More Intl Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.