My favorites | Sign in
Project Logo
                
Search
for
Updated Nov 23, 2008 by hhh333
I18N  

jquery.i18n.js

Author Copyright (c) 2008 Maxime Haineault (haineault.com)
License MIT License

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"

Tip

Encapsulate 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
Hosted by Google Code