W3cubDocs

/JavaScript

Intl.locale.Locale

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

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Locale() constructor 74 79 75 No 62 14
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Locale() constructor 74 74 No 53 14 11.0
Server
Node.js
Locale() constructor 13.0.0
13.0.0
12.0.0
Before version 13.0.0, only the locale data for en-US is available by default. When other locales are specified, the Locale instance silently falls back to en-US. To make full ICU (locale) data available for versions prior to 13, see Node.js documentation on the --with-intl option and how to provide the data.

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale