Intl.DisplayNames() constructor

The Intl.DisplayNames() constructor creates objects that enables the consistent translation of language, region and script display names.

Syntax

new Intl.DisplayNames([locales[, options]])

Parameters

locales Optional

A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the locales argument, see the Intl page. The following Unicode extension key is allowed:

nu
The numbering system to be used. Possible values include: "arab", "arabext", "bali", "beng", "deva", "fullwide", "gujr", "guru", "hanidec", "khmr", "knda", "laoo", "latn", "limb", "mlym", "mong", "mymr", "orya", "tamldec", "telu", "thai", "tibt".
options Optional

An object with some or all of the following properties:

localeMatcher
The locale matching algorithm to use. Possible values are "lookup" and "best fit"; the default is "best fit". For information about this option, see the Intl page.
style
The formatting style to use, the default is "long".
  • "narrow"
  • "short"
  • "long"
type
The type to use, the default is "language".
  • "language"
  • "region"
  • "script"
  • "currency"
fallback
The fallback to use, the default is "code".
  • "code"
  • "none"

Examples

Basic usage

In basic use without specifying a locale, a formatted string in the default locale and with default options is returned.

console.log((new Intl.DisplayNames()).of('US'));
// Expected output: 'us'

Specifications

Specification
Intl.DisplayNames
The definition of 'the Intl.DisplayNames constructor' in that specification.

Browser compatibility

DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
DisplayNames() constructorChrome Full support 81Edge Full support 81Firefox No support NoIE No support NoOpera Full support 68Safari No support NoWebView Android Full support 81Chrome Android Full support 81Firefox Android No support NoOpera Android Full support 58Safari iOS No support NoSamsung Internet Android No support Nonodejs Full support 14.0.0

Legend

Full support
Full support
No support
No support

See also