Last month, I wrote about how Microsoft is contributing code to jQuery , and also talked about some of the features included in the first batch of contributed code: jQuery templates and data linking support.
Today, we released a prototype of a new jQuery internationalization plug-in that you can reference in your JavaScript programs to add internationalization functionality. The plug-in covers international information for more than 350 cultures, from Scottish Gaelic, Frisian, Hungarian, Japanese to Canadian English, etc. The plug-in will be released as open source.
You can download a prototype version of the plugin from our Github repository:
http://github.com/nje/jquery-glob
You can also download some examples here to learn simple usage.
Understand internationalization
The jQuery internationalization plug-in allows you to easily handle number, currency, and date formats between different cultures in JavaScript code. For example, you can use this plugin to correctly display a country's currency symbol:
You can also use this plugin to format dates so that the days and months are displayed in the correct order and the day and month names are translated correctly:
Please note that in the Arabic date format above, the year is displayed as 1431. This is because the years have been converted according to the Hijri calendar.
Some cultural differences are obvious, such as the use of different currencies or different month names. But other differences are subtle and surprising. For example, in some cultures numbers are not grouped in a balanced way. In cultures whose language is marked "te-IN" (Telugu in eastern India), numbers are grouped first by 3 digits and then by 2 digits. So a number like one million (1000000) would be written as "10,00,000". And some cultures don't group numbers at all. All these subtle differences can be handled automatically by the jQuery internationalization plug-in.
Getting the date right can be tricky. Different cultures use different calendars, such as the Gregorian calendar and the Hijri calendar. The same culture may also use multiple calendars. For example, Japan uses both the Gregorian calendar and the chronological calendar based on the emperor's reign. The plugin provides functions to convert dates to and from all these calendars.
Use language tags
The jQuery internationalization plug-in identifies cultures based on the language tags defined in the RFC 4646 and RFC 5646 standards (see http://tools.ietf.org/html/rfc5646 ). The language tag is usually composed of multiple auxiliary tags combined with hyphens. ,for example:
Language tag language name (Chinese)
en-AU English (Australia)
en-BZ English (Belize)
en-CA English (Canada)
ID Indonesian
zh-CHS Chinese (Simplified) — tag no longer used
Zu Zulu
Please note that a single language such as English can have multiple language tags at the same time. Both are English-speaking countries, but Canada uses different number, currency and date formats than Australia or the United States. You can use the language tag lookup tool below to get the language tag for a culture: