The Intl.Locale
constructor is a standard built-in property of the Intl object that represents a Unicode locale identifier.
Syntax
new Intl.Locale(tag [, options])
Parameters
tag
- The Unicode locale identifier string.
options
- An object that contains configuration for the Locale. Keys are Unicode locale tags, values are valid Unicode tag values.
Examples
Basic usage
At its very simplest, the Intl.Locale
constructor takes a locale identifier string as its argument:
let us = new Intl.Locale('en-US');
Using the Locale constructor with an options object
The constructor also takes an optional configuration object argument, which can contain any of several extension types. For example, set the hourCycle
property of the configuration object to your desired hour cycle type, and then pass it into the constructor:
let us12hour = new Intl.Locale("en-US", {hourCycle: "h12"}); console.log(us12hour.hourCycle); // Prints "h12"
Specifications
Specification |
---|
ECMAScript Internationalization API (ECMA-402) |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Locale() constructor | Chrome Full support 74 | Edge Full support 79 | Firefox Full support 75 | IE No support No | Opera Full support 62 | Safari Full support 14 | WebView Android Full support 74 | Chrome Android Full support 74 | Firefox Android No support No | Opera Android Full support 53 | Safari iOS Full support 14 | Samsung Internet Android Full support 11.0 | nodejs
Full support
13.0.0
|
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
- See implementation notes.