1 of 10

Intl.DisplayNames �for Stage 4

Frank Yung-Fong Tang / 譚永鋒

ftang@google.com

TC39 September 2020 Meeting

September 21-24, 2020

Slide: https://docs.google.com/presentation/d/1SicCmt1bo4jyMTvAUiumCBW2ZqUh_-a18xrTO9nqG7U/edit

Proposal: https://tc39.es/proposal-intl-displaynames

Repo: https://github.com/tc39/proposal-intl-displaynames

2 of 10

Motivation & Sample Usages

Motivation

To enable developers to get human translation of language, region, script, and other display names on the client.

// Display names in English�let regionNames = new Intl.DisplayNames(� ['en'], {type: 'region'});�regionNames.of('US'); // => "United States"�regionNames.of('419'); // => "Latin America"�regionNames.of('MM'); // => "Myanmar (Burma)"

// Display names in Traditional Chinese�let regionNames = new Intl.DisplayNames(� ['zh-Hant'], {type: 'region'});�regionNames.of('US'); // => "美國"�regionNames.of('419'); // => "拉丁美洲"�regionNames.of('MM'); // => "緬甸"

let languageNames = new Intl.DisplayNames(� ['en'], {type: 'language'});�languageNames.of('fr'); // => "French" �languageNames.of('fr-CA'); �// => "French (Canada)"�languageNames.of('zh-Hant'); �// => "Chinese (Traditional)" �languageNames.of('en-US'); �// => "English (United States)"

Let languageNames = new Intl.DisplayNames(� ['zh-Hant'], {type: 'language'});�languageNames.of('fr'); // => "法文" �languageNames.of('fr-CA'); �// => "法文(加拿大)"�languageNames.of('zh-Hant'); �// => "繁體中文"�languageNames.of('en-US'); �// => "英文(美國)"

3 of 10

History of Stage Advancement

  • May 2018: Started Stage 0 Proposal repo
  • Jan 2019: Advanced to Stage 1 in TC39 meeting.
  • Jun 2019: Advanced to Stage 2 in TC39 meeting.
  • Oct 2019: Advanced to Stage 3 in TC39 meeting.
  • Aug 2020: v2 repo is created as Stage 0 to track additional feature requests (will be discussed later)
  • Sep 2020: Propose to Stage 4

4 of 10

Changes after Stage 3- type is now required

1.2.1 Intl.DisplayNames ( locales, options )

  • options in constructor change from optional to mandatory:

Intl.DisplayNames ( locales [ , options ] ) => Intl.DisplayNames ( locales , options )

  • type in option from default to “language” to mandatory:

12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », "language").

=>

12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined).

13. If type is undefined, throw a TypeError exception.

5 of 10

Changes after Stage 3 - Canonicalize code

1.4.3 Intl.DisplayNames.prototype.of ( code )

  • … Let code be ? CanonicalCodeForDisplayNames(displayNames.[[Type]], code).

Normative change

Editorial�changes

6 of 10

Browsers & JS Engines Implementation

Implemented in

Shipped in: Chrome m81 / Edge 81 / Opera 68 / Node.js 14

“Ready to ship” in: FireFox

Documentation: MDN Page

Test262: test/intl402/DisplayNames

Spec PR: https://github.com/tc39/ecma402/pull/502

7 of 10

8 of 10

Plans for v2 - Just FYI here

  • Fork off to discuss under a new Stage 0 proposal repo https://github.com/FrankYFTang/intl-displaynames-v2/
    • Mainly to add support for additional types
    • Also some minor additional options
  • Will be discussed later in it’s dedicated timeslot for Stage 1 discussion.

9 of 10

Pull Request to ECMA-402

10 of 10

Requesting the Committee Approval for advancement to Stage 4