Spec
https://tc39.github.io/proposal-intl-locale/
Summary
A Stage 3 proposal that introduces a new standard built-in property of the Intl object, which allows the following:
Parsing and manipulating the language, region and script of a locale
Reading or writing the Unicode extension tags in a locale
A serializable, standard format to store user locale preferences for use in Intl APIs rather than a combination of language and options bag.
For future proposals, a Locale class can be used for an interface to get at various kinds of locale data, including likely subtags, first day of the week, various display names, etc.
Allow Intl objects to take Intl.Locale object as item in the locales parameter in addition to the pre-existing string form.
let loc = new Intl.Locale("pl-u-hc-h12", { calendar: 'gregory' }); console.log(loc.language); // "pl" console.log(loc.hourCycle); // "h12" console.log(loc.calendar); // "gregory" console.log(loc.toString()); // "pl-u-ca-gregory-hc-h12" // use Intl.Locale in Intl.DateTimeFormat constructor let df = new Intl.DateTimeFormat([loc, "pl"]); // Add likely subtags to the locale console.log(loc.maximize().toString()); // "pl-Latn-PL-u-ca-gregory-hc-h12" // Remove likely subtags from locale console.log((new Intl.Locale("zh-Hant-TW")).minimize().toString()) // "zh-TW" console.log((new Intl.Locale("zh-Hans-CN")).minimize().toString()) // "zh" |
Interoperability and compatibility risk
The Intl.Locale is new and should have no risk to break pre-existing javascript code.
Firefox:In development
Edge:In development
Safari:No public signals
Web Developers:No signals
Is this feature fully tested?
Yes; our implementation passes our own V8 tests as well as the Test262 tests for all the features. To pass all the test262 tests, V8 is based on the latest ICU version 63 with 3 bug fixing patches (uloc1.patch, uloc2.patch, uloc3.patch), which are part of the coming ICU 64 (schedule to be released on March 29, 2019) release.
Tracking bug
Link to entry on the Chrome Platform Status dashboard
https://www.chromestatus.com/feature/4936310187884544
Requesting approval to ship?
Yes. Note that since this is a V8/JS feature, this post is just an FYI to blink-dev — no signoff from Blink API owners is required.
Tracking bug
Link to entry on the Chrome Platform Status dashboard
https://www.chromestatus.com/feature/4936310187884544
Requesting approval to ship?
Yes. Note that since this is a V8/JS feature, this post is just an FYI to blink-dev — no signoff from Blink API owners is required.