JavaScript Internationalization API Helps to Build a Global Web

Developers of Web applications that serve a global user base can more easily implement internationalization (i18n) in their applications thanks to a JavaScript Internationalization API.

As recently detailed in a post on the Mozilla Hacks blog, the ECMAScript Internationalization API provides a new Intl object that gives developers access to a number of methods that handle important i18n functions. Specifically, the methods allow developers to more gracefully handle date/time and number formatting, as well as collation.

For instance, using the API, developers can easily format numbers in local currencies; arrange data according to local conventions, including phonebook and dictionary sorting; and display dates using local numbering systems mixed with multiple calendar options.

According to Mozilla's Jeff Walden, the existing JavaScript i18n functionality had so many shortcomings that in many cases it was avoided. "[The] limitations are bad enough that — this surprised me greatly when I learned it! — serious Web applications that need i18n capabilities (most commonly, financial sites displaying currencies) will box up the data, send it to a server, have the server perform the operation, and send it back to the client. Server roundtrips just to format amounts of money," he explained.

Support for the Internationalization API has been present in Mozilla Firefox since Firefox 29. Firefox's implementation supports more than 400 locales for collation and over 600 locales for date/time and number formatting. Google's Chrome browser has also implemented the Internationalization API. According to the original specification, developers can identify whether a browser supports the API by checking for the presence of the Intl object. 

Global Web, More JavaScript

Today, the Web is truly global, and many of the largest Internet companies have more users outside of the United States than they do in it. Less than 25% of Facebook's users, for instance, are in the United States, and developing nations make up one of the social network's fastest-growing user segments.

While the Web's global footprint expands, JavaScript's popularity also continues to grow. More and more developers are building interactive applications that push functionality into the client and rely heavily on JavaScript. As such, JavaScript's ability to support internationalization is important.

The JavaScript Internationalization API does not provide a full localization solution, so developers will still need to rely on other tools to build fully localized apps, but it is a step in the right direction and gives developers the ability to avoid complex or less-performant workarounds.

Be sure to read the next Localization article: Four Ways Developers Can Grow Users and Revenue

 

Comments (0)