Web/JavaScript/Reference/Global objects/Intl/Locale/maximize
The Intl.Locale.prototype.maximize() method gets the most likely values for the language, script, and region of the locale based on existing values.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
locale.maximize()
Return value
A Locale instance whose baseName property returns the result of the Add Likely Subtags algorithm executed against locale.baseName.
Description
Sometimes, it is convenient to be able to identify the most likely locale language identifier subtags based on an incomplete langauage ID. The Add Likely Subtags algorithm gives us this functionality. For instance, given the language ID "en", the algorithm would return "en-Latn-US", since English can only be written in the Latin script, and is most likely to be used in the United States, as it is the largest English-speaking country in the world. This functionality is provided to JavaScript programmers via the maximize() method. maximize() only affects the main subtags that comprise the language identifier: language, script, and region subtags. Other subtags after the "-u" in the locale indentifier are called extension subtags and are not affected by the maximize() method. Examples of these subtags include Locale.hourCycle, Locale.calendar, and Locale.numeric.
Examples
Using maximize
let myLocale = new Intl.Locale("fr", {hourCycle: "h24", calendar: "gregory"});
console.log(myLocale.baseName); // Prints "fr"
console.log(myLocale.toString()); // Prints "fr-u-ca-gregory-hc-h24"
let myLocMaximized = myLocale.maximize();
// Prints "fr-Latn-FR". The "Latn" and "FR" tags are added,
// since French is only written in the Latin script and is most likely to be spoken in France.
console.log(myLocMaximized.baseName);
// Prints "fr-Latn-FR-u-ca-gregory-hc-h24".
// Note that the extension tags (after "-u") remain unchanged.
console.log(myLocMaximized.toString());
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 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.'
- See implementation notes.
See also
Intl.Locale.prototype.maximize() by Mozilla Contributors is licensed under CC-BY-SA 2.5.