Locale information should be separated from plugins

Locale information should be separated from plugins

I feel that the current way that jQuery UI plugins handle internationalization is rather messy and not maintainable in the longer term.

The current mechanism, afaict, is to fork your plugin code with a version for each locale you want to support, as datepicker does.

I recommend instead that locale information be separated from plugins and loaded separately. Since code size is important to web devs, you would only load those locales that your application needs on-demand.

I have written a simple jQuery plugin for managing this locale information

This plugin organizes localization information as follows

jquery.locale_name.json    // formatting values specific to a locale such as currency, dates, numbers

jquery.plugin_name.locale_name.json  //strings used in the plugin w/ their translations for locale locale_name

myapp.locale_name.json  //strings in my general application and their translation for locale locale_name 

Dividing up information this way may sound complex but it is quite lightweight and maintainable. 

Here is an example of storing that locale information for the Nepali locale

File: jquery.ne.json

$.i18n.ne = { date : 'dd/mm/yy', monetary: 'nn,nnnn.nn', currency: 'rs', numeralBase : 2406, numeralPrefix:"u0" /* * additional values that could be added * * monetary format * non-monetary numeric format * date format * time format * yes, no for yes, no questions */ };

This locale information would be accessed from a plugin using accessor and conversion methods.

I have written more in this announcement to the general jQuery forum


and in the README for my plugin

Almost no ideas in this plugin are original and most originate in the GNU C Library's localization API.