|
I18N
jquery.i18n.js
This is a plugin proposal to ease plugin translation. It currently support namespaces and language switching. Example
// Translation templates (always starts with english)
$.i18n('en.datePicker', {
'Month': 'Month',
'Year': 'Year',
'Day': 'Day'
});
$.i18n('fr.datePicker', {
'Month': 'Mois',
'Year': 'Année',
'Day': 'Jour'
});
$.i18n('en');
alert($.i18n('datePicker', 'Year')); // returns "Year"
$.i18n('fr');
alert($.i18n('datePicker', 'Year')); // returns "Année"
TipEncapsulate a shortcut function like this when writing your plugin
(function($){
function _(str, args) {
return $.i18n('datePicker', str, args);
}
// then you can use it like this
alert(_('Year')); // returns "Année"
})(jQuery);
|
Sign in to add a comment