444c1ec2fc
- Add support for translations in JavaScript code using babel lib and a custom PO file converter to JSON (using sepia/po-parser lib for PO files parsing) - Put translation CLI commands in a dedicated file - update_messages CLI command now provide PO file initialization feature using msginit and support of compendium files
26 lines
539 B
JavaScript
26 lines
539 B
JavaScript
/*
|
|
* 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();
|
|
});
|
|
});
|