1 of 21

ECMA-402 (Intl) status update

Shane Carr, Google i18n

March 2019 TC39 meeting

2 of 21

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"

3 of 21

How is Intl developed?

  • Separate specification also developed by TC39
  • Proposals move through TC39’s stage process
  • Monthly 2-hour phone call to discuss details
  • To join our monthly call: email ecma402-admin@chromium.org

4 of 21

Personnel

  • Editor: Isaac Durazo, Valerie Young, and Leo Balter
  • Chair: Shane Carr
  • Chief Advisor: Dan Ehrenberg

5 of 21

Pull requests

6 of 21

Pull requests

  • Normative: Support BigInt in NumberFormat and toLocaleString (#236, #318)
  • Timebox later in the meeting to discuss further (slides)

7 of 21

Stage 3 proposals

8 of 21

Intl.RelativeTimeFormat (Repo; Stage 3)

  • Shipped in Chrome 71 (ChromeStatus)
  • Shipped in Firefox 65 (without formatToParts 😵)
  • Documentation in MDN (Thanks Romulo Cintra!)
  • Test262 tests complete upstream
  • ICU support in ICU 64 (Thanks Shane!)

let rtf = new Intl.RelativeTimeFormat("en");��rtf.format(100, "day");�// "in 100 days"

9 of 21

Intl.Locale (Repo; Stage 3)

  • Multiple implementations in progress
  • Landed Use Unicode BCP47 Locale ID--Important simplification
    • Uncertainty had been blocking shipping

let loc = new Intl.Locale("en-US");�loc.language�// "en"

10 of 21

Intl.ListFormat (Repo; Stage 3)

  • Shipped in Chrome 72
  • Some minor open issues
  • ICU support in ICU 64 (Thanks Shane!)

let o = new Intl.ListFormat("en-GB");�o.format(['foo', 'bar', 'baz']�// "foo, bar, and baz"

11 of 21

Intl.Segmenter (Repo; Stage 3)

  • Decided to switch to break-based API; revision in progress

// 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;�}

12 of 21

Unified Intl.NumberFormat (Repo; Stage 3)

  • Adds Measurement Units, Compact Decimal Notation, and Sign Display
  • Issue involving data size for measurement units (#39); current plan is to restrict to a much smaller set of units for the initial launch (~12 simple units)

(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%

13 of 21

Stage 2 proposals

14 of 21

Intl.DateTimeFormat.prototype.formatRange()

  • Stage advancement proposal later this meeting!
  • ICU support in ICU 64 (Thanks, Shane!)

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"

15 of 21

dateStyle/timeStyle

  • Locale-dependent style, narrow/short/medium/full
  • Stage advancement proposal later this meeting!

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"

16 of 21

Stage 1 proposals

17 of 21

DisplayNames (Repo; Stage 1)

  • Discussions on the content (what display names to expose) and web need
  • Method name and signature changes: accept a list of codes instead of one code

Intl.DisplayNames([ locales [ , options ]])�Intl.DisplayNames.prototype.of( codes )�

18 of 21

TC39 Task Group

19 of 21

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.

Details Here

20 of 21

Get involved!

21 of 21

Get involved!

  • https://github.com/tc39/ecma402/
  • How you can help
    • Give feedback on open issues!
    • Implement in JS engines and polyfills
      • New effort in Globalize.js to match Intl API
    • Write Test262 tests
    • Add plumbing to ICU
    • Document proposals for developers
    • To join our monthly call: email ecma402-admin@chromium.org