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.
Example
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
<https://bugzilla.mozilla.org/show_bug.cgi?id=1433303>
-
Edge:In development <https://github.com/Microsoft/ChakraCore/pull/5675>
-
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
<https://cs.chromium.org/chromium/src/third_party/icu/patches/uloc1.patch>,
uloc2.patch
<https://cs.chromium.org/chromium/src/third_party/icu/patches/uloc2.patch>,
uloc3.patch
<https://cs.chromium.org/chromium/src/third_party/icu/patches/uloc3.patch>),
which are part of the coming ICU 64 (schedule to be released on March 29,
2019) release.
Tracking bug
https://crbug.com/v8/7684
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.
--
Frank Yung-Fong Tang
譚永鋒 / 🌭🍊
Sr. Software Engineer
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.