Considering that the whole purpose of JavaScript is to help provide interactive content on an international stage, one would expect to see globalization features either built into the language or widely available in libraries. But surprisingly, until the recent announcement from jQuery and Microsoft there wasn’t anything available.

Well that last statement isn’t entirely true. IBM does have a patent on JavaScript globalization using web services. But one probably doesn’t want to make a round-trip to the server just to determine if “10/1/2010” refers to January 10th or October 1st, so it is doubtful that this patent will ever be enforced.

jQuery’s Globalization library, developed in conjunction with Microsoft, provides full client-side globalization. With approximately 350 cultures in the list, it is bound to cover the formatting and parsing needs of most international web sites.

The actual features in jQuery’s Globalization are quite modest. After setting the jQuery.culture field to the desired language or language/country pair, you get access to parsing and formatting functions for dates, integers, and floating-point numbers.

The other feature you get out of the box is jQuery.localize. This is used to create resource dictionaries based on key/culture pairs. The values you store can in any form you wish, not just strings like most resource dictionaries. When retrieving the values, the engine looks for the best match on culture. For example, you can store localized strings for French (“fr”) and then provide country specific overrides for Canada (“fr-CA”). If at runtime it will look for a culture-country match first, and then check for just matching on culture.

By default jQuery only brings in the neutral English culture. Additional cultures are in separate JavaScript files that need to be reference individually. By inspecting the user’s culture ahead of time instead of bringing them all down one can significantly cut down on load and parsing costs.

jQuery Globalization is available on GitHub.