eesyphp/public_html/js/translation.js

27 lines
539 B
JavaScript
Raw Normal View History

/*
* I18n
*/
var lang = null;
var translations;
function _(string) {
var translated = translations.gettext(string);
return (translated !== '') ? translated : string;
}
function ngettext(singular, plural, n) {
return translations.ngettext(singular, plural, n);
}
$(document).ready( function() {
// Load Gettext translations
var catalog = {};
$.getJSON('translations/'+lang+'.json', function(data) {
catalog = data;
}).always(function() {
translations = babel.Translations.load(catalog).install();
});
});