Polite Notice: this implementation is not yet ready for production environments. See Status for more info.
In December 2012, ECMA International published the first edition of Standard ECMA-402, better known as the ECMAScript Internationalization API. This specification provides the framework to bring long overdue localisation methods to ECMAScript implementations.
Google have an implementation of this API that is available in recent versions of V8 and Chrome/Chromium 24 and later. Mozilla also have a working implementation in the current Firefox nightly builds.
Intl.js
attempts to fill the void of availability for this API. It will provide the
framework as described by the specification, so that developers can take advantage of
the native API in environments that support it, or Intl.js
for legacy or unsupporting
environments.
Intl.js
isn't yet ready for production environments. test402 has been integrated into
the project and tells us there's still a lot of work to be done. The latest test, run on
May 27 2013, scored 90 out of 153*.
Current progress is as follows:
- All internal methods except for some that are implementation dependent
- Checking structural validity of language tags
- Canonicalizing the case and order of language subtags
Intl.NumberFormat
Intl.DateTimeFormat
- Locale Sensitive Functions of the ECMAScript Language Specification
- Canonicalizing language tags containing subtags that have a "Preferred-value" from the IANA Language Subtag registry
BestFitSupportedLocales
internal function- Implementation-dependent numbering system mappings
- Collator objects (
Intl.Collator
) - Properties of the
String
prototype object - Test suites
A few of the implemented functions may currently be non-conforming and/or incomplete.
Most of those functions have comments marked as 'TODO' in the source code.
* some of the tests cannot be passed from an ES5 implementation because they check for native behaviour. The majority of them should be passable, though.
Intl.js is designed to be compatible with ECMAScript 3.1 environments in order to follow the specification as closely as possible. However, some consideration is given to legacy (ES3) environments, and the goal of this project is to at least provide a working, albeit non-compliant implementation where ES5 methods are unavailable.
The main Intl.js
file contains no locale data itself. Instead, the data should be
provided, parsed into a JavaScript object, using the Intl.__addLocaleData()
method.
Intl.js
uses the Unicode CLDR locale data, as recommended by the specification.
The data is available in JSON format, or JSONP format in the locale-data
folder. This has been converted from CLDR version 23.1 using the script and config file
in the tools folder.
Collation data isn't currently present since the Intl.Collator
implementation isn't
finished.