Overview page that shows what solutions exist for JavaScript globalization (internationalization and localization). What is missing. What overlaps. Why each library was created. What are their goals, strengths and weaknesses.
The standard native implementation. It provides collation (string comparison), number formatting, and date and time formatting. The API was developed by a working group with members from Google, Microsoft, Mozilla (Norbert Lindenberg), Amazon, and IBM.
Strengths
- Best performant on both speed and size. Speed, because it's native compiled code, which runs faster than interpreted JavaScript code from libraries. Size, because again it's native compiled code, which requires no extra JavaScript or resource loading (it relies on compiled i18n data) to be executed.
Weaknesses
- Limited browser support (it may NOT be supported by your target client).
- Lack of a resource loading mechanism (certain locale may NOT be available on your target client).
Links
- http://www.ecma-international.org/ecma-402/1.0/
- http://norbertlindenberg.com/2012/12/ecmascript-internationalization-api/index.html
- http://generatedcontent.org/post/59403168016/esintlapi (locale support)
Standalone library created by Santhosh Thottingal that provides CLDR plural rule parsing. Used by Wikimedia Foundation.
Strengths
- Based on CLDR data (largest and most extensive i18n repository).
- No bugs due to outdated i18n content (it has no hard coded i18n data).
Links:
A jQuery project, initially created to fullfil jQuery UI (datepicker and spinner widgets). It provides number formatting and parsing, date and time formatting and parsing, message formatting, and plural support.
The design goals are (a) to leverage the official CLDR JSON data, (b) allow users to load as much or as little data as they need, (c) avoid duplicating data if using multiple i18n libraries that leverage CLDR, and (d) run in browsers or node.js.
Strengths
- Based on CLDR data (largest and most extensive i18n repository).
- No bugs due to outdated i18n content (it has no hard coded i18n data).
- Allow different locale instances running simultaneously.
Links:
Part of the larger Closure library, based on CLDR data. Provides number formatting and parsing, date and time formatting and parsing, message formatting (including plural and gender support), access to some of the CLDR data (like currency symbols).
Strenghts
- Based on CLDR data (largest and most extensive i18n repository).
Weaknesses
- Supports only one locale at the time (default model, can be bypassed).
Links
Standalone library created by Alex Sexton that provides ICU MessageFormat support, with built-in SelectFormat and pluggable PluralFormat.
Strengths
- Precompile formatter for faster/smaller runtime.
Links:
FormatJS is a modular collection of JavaScript libraries for internationalization that are focused on formatting numbers, dates, and strings for displaying to people. It includes a set of core libraries that build on the JavaScript Intl
built-ins and industry-wide i18n standards, plus a set of integrations for common template and component libraries.
Strengths:
- Integrates with template/component libraries: Handlebars, React, and Dust.
- Modular, integration libs (above) are built on core libraries: intl-mesageformat, intl-relativetime.
- IE6+ support, automated testing in IE7+.
- Built on standards: ECMA-402, CLDR, and ICU Message syntax.
Weaknesses:
- No parsing beyond what the
Date
andNumber
build-ins provide.
Links:
- http://formatjs.io/
- http://formatjs.io/github/ (packages)
ECMA-402 Native |
Cldrpluralruleparser santhoshtr/cldrpluralruleparser |
Globalize jquery/globalize |
Messageformat.js slexaxton/messageformat.js |
FormatJS formatjs.io |
|
---|---|---|---|---|---|
Functionality | |||||
Date Formatnew Date() ⟹ Oct 23, 2014, 9:00:00 AM |
✔️ | ✔️ | ✔️ Via ECMA-402 or its polyfil |
||
Date Parse Oct 23, 2014, 9:00:00 AM ⟹ new Date() |
✔️ | ||||
Relative Time Formatnew Date() ⟹ last month |
🔜 | ✔️ Via intl-relativeformat |
|||
Number Format12734.89 ⟹ 12,734.89 |
✔️ | ✔️ | ✔️ Via ECMA-402 or its polyfil |
||
Number Parse 12,734.89 ⟹ 12734.89 |
✔️ | ||||
Currency Format{EUR: 1000.00} ⟹ €1,000.00 |
✔️ | 🔜 | ✔️ Via ECMA-402 or its polyfil |
||
Currency Parse €1,000.00 ⟹ {EUR: 1000.00} |
🔜 | ||||
Plural3 ⟹ few |
✔️ | ✔️ Powered by santhoshtr/cldrpluralruleparser |
✔️ | ||
Message FormatYou have {count, plural, one {1 item} other {# items}} ⟹ You have 5 items |
✔️ Powered by slexaxton/messageformat.js |
✔️ | ✔️ Via intl-messageformat |
||
Template integration | Handlebars React Dust |
||||
Collation | ✔️ | ||||
I18n data | Compiled | CLDR >= 25 | CLDR | ||
Support | |||||
Environments | Globals | AMD CommonJS Globals |
AMD CommonJS Globals |
AMD CommonJS Globals |
ES6 CommonJS Globals |
Node.js | >= 0.12en only by default |
✔️ | ✔️ | ✔️ | ✔️ |
Browser | Chrome: 24 Firefox: 29 Safari: N/A Opera: 15 IE: 11 Reference MDN. |
Chrome: (Current - 1) or Current Firefox: (Current - 1) or Current Safari: 5.1+ Opera: 12.1x, (Current - 1) or Current IE: 8 (needs ES5 polyfill), IE9+ |
All ES3+ including IE6 | ||
Mobile | iOS: 6.1+ Android: 2.3, 4.0+ |
✔️ |