1 of 18

ECMA-402 (Intl) status update

Daniel Ehrenberg, ECMA-402 interim editor

Igalia, in partnership with Mozilla

November 2018 TC39 meeting

2 of 18

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 18

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
  • Contact Dan for an invitation to the call, littledan@igalia.com

4 of 18

Pull requests

5 of 18

Pull requests

  • Specify enumeration order of resolvedOptions (PR)
  • Normative: Don't harden supportedLocalesOf Array (PR)

6 of 18

Stage 3 proposals

7 of 18

Intl.RelativeTimeFormat (Repo; Stage 3)

  • Shipping in Chrome 71 (ChromeStatus), in progress in SpiderMonkey
  • Test262 tests complete upstream
  • Supporting ICU API in progress

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

8 of 18

Intl.Locale (Repo; Stage 3)

  • V8, SpiderMonkey, ChakraCore implementations in progress
  • Test262 tests complete upstream (modulo recent change)
  • Semantic changes
    • Use Unicode BCP47 Locale ID--Important simplification

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

9 of 18

Intl.ListFormat (Repo; Stage 3)

  • V8 implementation complete behind a flag; in progress in SpiderMonkey
  • Test262 tests complete upstream

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

10 of 18

Intl.Segmenter (Repo; Stage 3)

  • Complete implementation in V8 behind a flag
  • Tests landed in test262

// 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!�for (let {segment, breakType} of iterator) {� console.log(`segment: ${segment} breakType: ${breakType}`);� break;�}

11 of 18

Stage 2 proposals

12 of 18

Additional Intl.NumberFormat options

  • Stage 3 proposal coming later this meeting!

13 of 18

Intl.DateTimeFormat.prototype.formatRange()

  • Still undergoing changes; Stage 3 in January

14 of 18

Stage 0/1 proposals

15 of 18

dateStyle/timeStyle

  • Locale-dependent style, narrow/short/medium/full
  • Stage 1; Proposed for Stage 2 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 18

DisplayNames

Stage 0

(Fill in details soon)

17 of 18

Get involved!

18 of 18

Get involved!

  • https://github.com/tc39/ecma402/
  • How you can help
    • Review proposals and file issues on GitHub
    • 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
    • Contact Dan for an invitation to the Intl call, littledan@igalia.com