FormatJS: Localize dates and numbers

Home » Blog » Software » FormatJS: Localize dates and numbers

Internationalization and localization still is a somewhat difficult problem in software development. FormatJS is a collection of JavaScript libraries that addresses a part of this problem by formatting dates and numbers according to a selected locale.

It makes clever use of pluralization and natural language patterns so the output strings read like a natural language utterance instead of a computer-generated string, for example it generates these outputs for 0, 1 and 1,000 items, respectively:

“Annie took no photos on December 14, 2014.”
“Annie took one photo on December 14, 2014.”
“Annie took 1,000 photos on December 14, 2014.”

FormatJS applies similar logic to date representations. Today (21-12-2014) the abstract date “2014-11-21” for instance is represented as “last month”, “1 month ago” or “31 days ago”.

FormatJS works both in the browser and in JavaScript server environments such as node.js. While not a catch-all solution for all your i18n woes it’s a very useful library for elegantly solving a specific problem in this space.

About the author: Bjoern
Independent IT consultant, entrepreneur

Leave a Comment