ECMA-402 (Intl) status update
Shane Carr, Google i18n
March 2019 TC39 meeting
What is ECMA-402?
JavaScript’s built-in internationalization library
var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
new Intl.DateTimeFormat('en-US').format(date);
// "12/20/2012"
new Intl.DateTimeFormat('en-GB').format(date);
// "20/12/2012"
How is Intl developed?
Personnel
Pull requests
Pull requests
Stage 3 proposals
Intl.RelativeTimeFormat (Repo; Stage 3)
let rtf = new Intl.RelativeTimeFormat("en");��rtf.format(100, "day");�// "in 100 days"
Intl.Locale (Repo; Stage 3)
let loc = new Intl.Locale("en-US");�loc.language�// "en"
Intl.ListFormat (Repo; Stage 3)
let o = new Intl.ListFormat("en-GB");�o.format(['foo', 'bar', 'baz']�// "foo, bar, and baz"
Intl.Segmenter (Repo; Stage 3)
// Create a segmenter in your locale�let segmenter = new Intl.Segmenter("fr", {granularity: "word"});��// Get an iterator over a string�let iterator = segmenter.segment("Ceci n'est pas une pipe");��// Iterate over it!�// NOTE: This will change after switching to a break-based API�for (let {segment, breakType} of iterator) {� console.log(`segment: ${segment} breakType: ${breakType}`);� break;�}
Unified Intl.NumberFormat (Repo; Stage 3)
(9.81).toLocaleString("en-US", {� style: "unit",� unit: "meter-per-second",� unitDisplay: "short"�});�// ==> "9.81 m/s²"
(987654321).toLocaleString("en-US", {
notation: "compact",
compactDisplay: "long"
});
// ==> 987.7 million
(0.55).toLocaleString("en-US", {
style: "percent",
signDisplay: "except-zero"
});
// ==> +55%
Stage 2 proposals
Intl.DateTimeFormat.prototype.formatRange()
let date1 = new Date(Date.UTC(2007, 0, 10, 10, 0, 0));�let date3 = new Date(Date.UTC(2007, 0, 20, 10, 0, 0));�let fmt2 = new Intl.DateTimeFormat("en",� { year: 'numeric', month: 'short', day: 'numeric' });�console.log(fmt2.formatRange(date1, date3));�// "Jan 10 – 20, 2007"
dateStyle/timeStyle
let o = new Intl.DateTimeFormat("en" , { timeStyle: "short" });�console.log(o.format(Date.now())); // "13:31"�let o2 = new Intl.DateTimeFormat("en" , { dateStyle: "short" });�console.log(o2.format(Date.now())); // "21.03.2012"�let o3 = new Intl.DateTimeFormat("en" , { timeStyle: "medium", dateStyle: "short" });�console.log(o3.format(Date.now())); // "21.03.2012, 13:31"
Stage 1 proposals
DisplayNames (Repo; Stage 1)
Intl.DisplayNames([ locales [ , options ]])�Intl.DisplayNames.prototype.of( codes )�
TC39 Task Group
TC39 Task Group
ECMA-402 has been having monthly 2-hour phone meetings since December 2017. We work out the details of Intl-related proposals and bring those recommendations to TC39.
We would like to formalize our role and responsibilities as a TC39 Task Group under Section 7 of the ECMA Rules for a RFTG.
Get involved!
Get involved!