Widening the Web with ECMA-402: Our work on the Internationalization Extension to JavaScript

Inconsistencies across browser implementations have caused web authors and users headaches since the dawn of time (or at least Jan 1, 1970), but nowhere has that pain been felt more acutely than in the realm of language and regional internationalization and localization.

We have an inclusion gap on the web. Web authoring tools structurally exclude the language and formatting of many cultures. This has resulted in the bulk of the web’s content being exclusively available in English, despite the majority of the world not speaking English as a first language. JavaScript has an internationalization extension which will help authors support many locales, and I am pleased to share that Bocoup is providing three team members to co-edit ECMA-402, the specification for this extension: myself (en-US), Leo Balter (pt-BR), and Isaac Durazo (es-MX).

Let’s take a minute to talk through some of the scenarios which this new internationalization built-in is designed to help solve. Dates, for example, are formatted differently across cultures, and for folks interpreting dates across cultures, this can be confusing. Without proper date localization, we can put people at risk of missing a deadline to apply for a visa, or the date of a plane flight, or the deadline for a bill. It doesn’t stop at dates. These kinds of issues could cause someone to order the wrong amount of a material due to a unit translation error, or pay a price different than expected due to a lack of proper number formatting.

The web is a utility that is increasingly necessary for civic and economic participation in society. If we want to center the rights and safety of people marginalized in our society—immigrants and refugees, folks connecting to the web for the first time—then we have to make sure that the core programming tools we use support diverse locales natively. Building internationalization into the web platform is an issue of social justice.

Thankfully, the technical committee that specifies JavaScript—TC39—came to the same conclusion in 2010, and at that time began work on an internationalization extension to the JavaScript language. Development of the standard has been ongoing for 9 years. Since its release, all major browsers have adopted it and new features specified in ECMA-402 have been developed and incorporated. You no longer need to write your own algorithm to translate a date from United States English to Mexican Spanish (or install one of the many impressive JavaScript internationalization libraries!)—you simply need to call a built-in function:

const date = new Date(Date.UTC(2016, 2, 3, 0, 0, 0));

console.log(new Intl.DateTimeFormat('en-US').format(date));
// “3/2/2016"

console.log(new Intl.DateTimeFormat('es-MX').format(date));
// “2/3/2016”

What is in ECMA-402, and why?

ECMA-402 is written and maintained by the same group that writes ECMAScript: Ecma’s Technical Committee 39, or, TC39. Prior to 2019, there was no differentiation within TC39 for work on ECMAScript (the language specification) and Internationalization (the language’s internationalization specification); in March of 2019, TC39-TG1 was created for “General ECMAScript® Language” and TC39-TG2 was created for “ECMAScript® Internationalization API Specification”. New feature proposals come at the recommendation of committee delegates, and are carefully crafted and reviewed by delegates within TG2 over the course of many months (sometimes years), and are subject to the same Staging Process that is used for ECMA-262.

Many of the goals for ECMA-402 were clear from the beginning. If we want a web that serves all language speakers, it is the responsibility of the web platform to provide built-in capabilities that support web authors with this task. The original feature set released in 2012 focused on internationalizing the features that already exist in ECMAScript, such as formatting date and time strings, string comparison for sorting (collation) and number formatting. You can read a summary of all these features at the time of release from ECMA-402’s first editor, Norbert Lindenberg.

Since then, TC39 has included member org representatives (or “delegates”) who have worked on existing internationalization libraries for JavaScript, such as moment.js and Format.js. The committee has drawn inspiration from these impressive projects to decide on what to incorporate next into ECMA-402. Additionally the committee seeks feedback from JavaScript developers at large: to request and suggest features you can submit an issue on the ECMA-402 repo. All new issues will be reviewed by the monthly meeting of the ECMA-402 task group and prioritized in our backlog.

A new cycle of ECMA-402 editing

After a tour as ECMA-402 editor of the 2nd edition, published in 2015, Bocoup team member Rick Waldron passed off leadership to Caridy Patiño. In January 2019, editorship came back to Bocoup team member Leo Balter, and we’re now working on the 7th edition. We at Bocoup are excited about this re-investment, as ECMA-402 aligns deeply with Bocoup’s values of access, inclusion and justice in the production of the Web Platform. We are always looking for opportunities to contribute to the inclusivity and reliability of the web, as you can see in our work on testing JavaScript implementations and in testing and contributing to the WAI-ARIA specification. As such, we have decided to give ECMA-402 a multi-person, multi-role editorial team, consisting of myself, Leo Balter and Isaac Durazo as co-editors. Leo and I focus on specification prose authoring and editing, while Isaac provides spec-wide project management. In March, lead by Isaac and Shane Carr (convener of the ECMA-402’s task group), we immediately got to work organizing the tasks on ECMA-402 github into a project board.

Making 402 More Inclusive

This is the first time we have had more than one editor on ECMA-402, and the first time we have had a project manager on an Ecma specification. We hope that this will help us bring a broader view and better prioritization to the development of the standard. This is also the first time we have had a woman editor for either ECMA-402, or any of the standards maintained by Ecma’s TC39.

Two co-editors at Bocoup are also not native English speakers. Isaac’s first language is Spanish, and Leo’s is Portuguese. In ECMA-402 meetings, and while reading the specification, I can already see how those with foreign language experience are able to bring insightful use cases and perspectives to the issues at hand, influencing specification decisions. I’m thankful to participate in an effort that affords so many learning and teaching opportunities, both with colleagues directly and with the broader web community around the world.

This year the editorial team hopes to discover new ways to help the community request features and communicate their internationalization needs. If you have ideas, please open an issue in our repo and we will actively keep track of it.

Can you use JavaScript’s internationalization extensions in web applications today?

Browser support for ECMA-402, where implemented, is looking better than ever. We’re on the verge of having robust cross browser support. Implementations are tested and reported daily at test262.report/browse/intl402, a website that runs the entire ECMAScript conformance test suite on all 4 major JavaScript implementations, which we launched in November 2018.

On the front page of test262.report you can see the “Internationalization API” tests have lower cross-browser pass rates than the rest of ECMAScript. This is primarily due to failing tests for new features which are undergoing development. You will also see that Edge has fallen behind the other browsers on Internationalization support in ChakraCore. Edge is currently migrating to Chromium, and will use V8 (Chrome’s JS engine) under the hood, which means it will benefit from the existing support for Internationalization (and other new language features that V8 has a lead on implementing). The other ECMAScript implementations to track on test262.report are SpiderMonkey (Firefox’s JS engine), JavaScriptCore (Safari’s JS engine).

Here is a table of feature support – based on Test262 data – separated into three categories: (1) the original feature set of ECMA-402, (2) recently released features and (3) features that are currently undergoing the standardization process and are in the final stage, implementation in browsers. Clicking on the first column will take you the MDN documentation for the feature. A click on any of the cells for features undergoing development, will bring you to the daily updated test262.report page for that feature. There, you can check on the current cross browser status of new features by test pass rates for those features. You should especially take a peak if you are reading this in a few months, or years, from the publishing of this article in May 2019.

Legend
Greater than 90% You can rely on this feature in this JS engine in standalone applications. Only rely on this feature on the web once support is cross browser. If support is less than 100%, then this engines implementation is not entirely conformant with the standard, so keep an eye out for unusual bugs.
Less than 90% This feature has only been partially implemented and not in conformant with the standard. We do not recommend relying on it.
Less than 50% This feature has not been implemented or it’s implementation is ongoing.
Edge < 76 (ChakraCore) icon Safari (JavaScriptCore) Firefox (SpiderMonkey) Chrome and Edge v76 (V8)
Original Feature Set
Collation (string sorting) 75% 95% 97% 98%
Date and Time Formatting 77% 95% 96% 94%
Number Formatting 77% 84% 94% 90%
Recently Released Features
Pluralization 75% 100% 100% 100%
Date and Time FormatToParts 83% 100% 100% 100%
Number FormatToParts 71% 100% 100% 100%
Features In Development
Relative Time Formatting 0% 0% 76% 100%
Date and Time Ranges Formatting 13% 13% 13% 100%
List Formating 0% 0% 0% 100%
Date and Time `datestyle` and `timestyle` options 0% 0% 0% 100%
Locale handling 0% 0% 0% 100%
Unit Formatting 0% 0% 0% 0%

Comments

Contact Us

We'd love to hear from you. Get in touch!

Phone

+1 617-379-2752

Mail

P.O. Box 961436
Boston, MA 02196