## ECMA-402 (Intl) Status Update ### Ujjwal Sharma (@ryzokuken) ### TC39 July 2021, 日本 🇯🇵 --- ## What is ECMA-402? 🤔 JavaScript's built-in internationalization library. ```javascript 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" new Intl.DateTimeFormat('ja-JP').format(date); // "2012/12/20" ``` --- ### How is ECMA-402 developed? 👩‍🏭 * [Separate specification](https://github.com/tc39/ecma402/) developed by TC39-TG2 * 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 * More information: https://github.com/tc39/ecma402 --- ## Normative Pull Requests 🖌 --- ## Add Lower case mapping definition in 6.1 ([#577](https://github.com/tc39/ecma402/pull/577)) * Authored by Frank Tang (FYT). * Fixes [#576](https://github.com/tc39/ecma402/issues/576). * Pointed out by @anba while reviewing `DisplayNames` v2. * Multiple positive reviews. --- # Consensus? 😇 --- ## Stage 3 Proposals 🛠 --- ## [Intl.Segmenter](https://github.com/tc39/proposal-intl-segmenter) * Champion: Richard Gibson (RGN) * Shipping in V8 and JSC, SM pending * Tests added ```javascript // Create a segmenter in your locale let segmenter = new Intl.Segmenter("en", {granularity: "word"}); // Iterate over a string! for (let { index, segment, isWordLike } of segmenter.segment("hello world")) { console.log((isWord?"Word":"Non-word")+" '"+segment+"' @ "+index); } // => "Word 'hello' @ 0", "Non-word ' ' @ 5", … ``` --- ## [Intl Locale Info](https://github.com/tc39/proposal-intl-locale-info) * Champion: Frank Tang (FYT) * V8 harmony, JSC and SM pending * Tests added ```javascript const jaJP = new Intl.Locale("ja-JP") jaJP.calendars // ["gregory", "japanese"] jaJP.collations // ["unihan", "emoji", "eor"] jaJP.hourCycles // ["h23"] jaJP.numberingSystems // ["latn"] jaJP.timeZones // ["Asia/Tokyo"]} const enUS = new Intl.Locale("en-US") enUS.calendars // ["gregory"] enUS.collations // ["emoji", "eor"] enUS.hourCycles // ["h12"] enUS.numberingSystems // ["latn"] enUS.timeZones // ["America/Adak", "America/Anchorage", "America/Boise", "America/Chicago", "America/Denver", "America/Detroit", "America/Indiana/Knox", "America/Indiana/Marengo", "America/Indiana/Petersburg", "America/Indiana/Tell_City", "America/Indiana/Vevay", "America/Indiana/Vincennes", "America/Indiana/Winamac", "America/Indianapolis", "America/Juneau", "America/Kentucky/Monticello", "America/Los_Angeles", "America/Louisville", "America/Menominee", "America/Metlakatla", "America/New_York", "America/Nome", "America/North_Dakota/Beulah", "America/North_Dakota/Center", "America/North_Dakota/New_Salem", "America/Phoenix", "America/Sitka", "America/Yakutat", "Pacific/Honolulu"] ``` --- ## [Intl.DisplayNames v2](https://github.com/tc39/intl-displaynames-v2) * Champion: Frank Tang (FYT) * V8 harmony and SM nightly, JSC pending * Tests wanted! ```javascript dn = new Intl.DisplayNames("en", {type: "calendar"}) dn.of("roc") // "Minguo Calendar" dn.of("persian") // "Persian Calendar" dn.of("gregory") // "Gregorian Calendar" dn.of("ethioaa") // "Ethiopic Amete Alem Calendar" dn.of("japanese") // "Japanese Calendar" dn.of("dangi") // "Dangi Calendar" dn.of("chinese") // "Chinese Calendar" dn = new Intl.DisplayNames("ja", {type: "calendar"}) dn.of("roc") // "中華民国暦" dn.of("persian") // "ペルシア暦" dn.of("gregory") // "西暦(グレゴリオ暦)" dn.of("ethioaa") // "エチオピア創世紀元暦" dn.of("japanese") // "和暦" dn.of("dangi") // "ダンギ暦" dn.of("chinese") // "中国暦" ``` --- ## [Extend timeZoneName](https://github.com/tc39/proposal-intl-extend-timezonename) * Champion: Frank Tang (FYT) * V8 harmony and SM nightly, JSC pending * Tests wanted! ```javascript let timeZoneNames = ["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"]; timeZoneNames.forEach(function(timeZoneName) { print(timeZoneName + ": " + (new Date()).toLocaleTimeString("en", {timeZoneName})) }); // short: 12:27:10 PM PST // long: 12:27:10 PM Pacific Standard Time // shortOffset: 12:27:10 PM GMT-8 // longOffset: 12:27:10 PM GMT-08:00 // shortGeneric: 12:27:10 PM PT // longGeneric: 12:27:10 PM Pacific Time timeZoneNames.forEach(function(timeZoneName) { print(timeZoneName + ": " + (new Date()).toLocaleTimeString("ja", {timeZoneName})) }); // short: 1:28:08 GMT+5:30 // long: 1時28分08秒 インド標準時 // shortOffset: 1:28:08 GMT+5:30 // longOffset: 1:28:08 GMT+05:30 // shortGeneric: 1:28:08 インド時間 // longGeneric: 1:28:08 インド標準時 ``` --- ## Stage 2 and 1 Proposals 🔨 * `Intl.DurationFormat` (Stage 2, USA) * `Intl.NumberFormat` v3 (Stage 2, SFC, ⬆) * `Intl` Enumeration API (Stage 2, FYT, ⬆) * Smart Unit Preferences (Stage 1, YMD) * `Intl.DateTimeFormat` eraDisplay (Stage 1, LAF) * `Intl` LocaleMatcher (Stage 1, LHO) --- ## Get involved! 👨‍🔧 * https://github.com/tc39/ecma402/ * How you can help * Give feedback on open issues! * Write MDN documentation: https://github.com/tc39/ecma402-mdn * Implement in JS engines and polyfills * Write Test262 tests * Add plumbing to ICU * To join our monthly call: email ecma402-admin@chromium.org --- # ありがとう! 🙏
{"title":"ECMA-402 Status Update","type":"slide"}