Intl.Locale.prototype.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.

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.hourCycleLocale.calendar, and Locale.numeric.

Examples

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". Notice that the extension tags (after "-u") remain unchanged.
console.log(myLocMaximized.toString()); 

Specifications

Specification Status Comment
Intl.Locale.prototype.maximize proposal

Browser compatibility

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
maximizeChrome Full support 74Edge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android Full support 74Chrome Android Full support 74Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No

Legend

Full support  
Full support
No support  
No support

See also

Document Tags and Contributors

Contributors to this page: jahzielv, SphinxKnight, sideshowbarker
Last updated by: jahzielv,