Web/JavaScript/Reference/Global objects/Intl/Locale
The Intl.Locale object is a standard built-in property of the Intl object that represents a Unicode locale identifier.
Description
The Intl.Locale object was created to allow for easier manipulation of Unicode locales. Unicode represents locales with a string, called a locale identifier. The locale identifier consists of a language identifier and extension tags. Language identifiers are the core of the locale, consisting of language, script, and region subtags. Additional information about the locale is stored in the optional extension tags. Extension tags hold information about locale aspects such as calendar type, clock type, and numbering system type.
Traditionally, the Intl API used strings to represent locales, just as Unicode does. This is a simple and lightweight solution that works well. Adding a Locale class, however, adds ease of parsing and manipulating the language, script, and region, as well as extension tags.
Constructor
Intl.Locale()- Creates a new
Localeobject.
Instance properties
Intl.Locale.prototype.baseName- Returns basic, core information about the
Localein the form of a substring of the complete data string. Intl.Locale.prototype.calendar- Returns the part of the
Localethat indicates the Locale's calendar era. Intl.Locale.prototype.caseFirst- Returns whether case is taken into account for the locale's collation rules.
Intl.Locale.prototype.collation- Returns the collation type for the
Locale, which is used to order strings according to the locale's rules. Intl.Locale.prototype.hourCycle- Returns the time keeping format convention used by the locale.
Intl.Locale.prototype.language- Returns the language associated with the locale.
Intl.Locale.prototype.numberingSystem- Returns the numeral system used by the locale.
Intl.Locale.prototype.numeric- Returns whether the locale has special collation handling for numeric characters.
Intl.Locale.prototype.region- Returns the region of the world (usually a country) associated with the locale.
Intl.Locale.prototype.script- Returns the script used for writing the particular language used in the locale.
Instance methods
Intl.Locale.prototype.maximize()- Gets the most likely values for the language, script, and region of the locale based on existing values.
Intl.Locale.prototype.minimize()- Gets the most likely values for the language, script, and region of the locale based on existing values.
Intl.Locale.prototype.toString()- Returns the Locale's full locale identifier string.
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.
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Locale
|
Chrome
Full support 74 |
Edge
Full support 79 |
Firefox
Full support 75 |
IE
No support No |
Opera
Full support 62 |
Safari Full support 14 Full support 14 Notes' Safari 14 Technology Preview 107-111 returns a string instead of a Locale object from the minimize and maximize methods. |
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 Full support 14 Notes' Safari 14 Technology Preview 107-111 returns a string instead of a Locale object from the minimize and maximize methods. |
Samsung Internet Android
Full support 11.0 |
nodejs Full support 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
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 Full support 13.0.0 Partial support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
baseName
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
calendar
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
caseFirst
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
collation
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
hourCycle
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
language
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
maximize
|
Chrome
Full support 74 |
Edge
Full support 79 |
Firefox
Full support 75 |
IE
No support No |
Opera
Full support 62 |
Safari Full support 14 Full support 14 Notes' Safari 14 Technology Preview 107-111 returns a string instead of a Locale object. |
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 Full support 14 Notes' Safari 14 Technology Preview 107-111 returns a string instead of a Locale object. |
Samsung Internet Android
Full support 11.0 |
nodejs Full support 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
minimize
|
Chrome
Full support 74 |
Edge
Full support 79 |
Firefox
Full support 75 |
IE
No support No |
Opera
Full support 62 |
Safari Full support 14 Full support 14 Notes' Safari 14 Technology Preview 107-111 returns a string instead of a Locale object. |
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 Full support 14 Notes' Safari 14 Technology Preview 107-111 returns a string instead of a Locale object. |
Samsung Internet Android
Full support 11.0 |
nodejs Full support 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
numberingSystem
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
numeric
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
region
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
script
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
toString
|
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 12.0.0 Full support 12.0.0 Notes' Before version 13.0.0, only the locale data for |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.'
- See implementation notes.
See also
Intl.Locale by Mozilla Contributors is licensed under CC-BY-SA 2.5.