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
fills 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.
For Node.js applications, you can install Intl.js using NPM:
npm install intl
Intl.js is also available as a Bower component for the front-end:
bower install intl
For other setups, just clone the repo for the pre-built scripts and locale datafiles.
In browser environments, the library will try to patch the browser by defining
the global Intl
is not defined. An example of usage might look like this: