eesyphp/static/js/translation.js
Benjamin Renard 4f47dc056d Tpl: Add stuff to handle static files
* Move example application in example sub-directory
* Widely use App::get() instead of Config::get()
2023-02-12 00:30:36 +01:00

23 lines
515 B
JavaScript

/*
* I18n
*/
var translations;
var translations_data;
function _(string) {
var translated = (translations?translations.gettext(string):string);
return (translated !== '') ? translated : string;
}
function ngettext(singular, plural, n) {
return (
translations?
translations.ngettext(singular, plural, n):
(n > 1?plural:singular)
);
}
$(document).ready( function() {
// Load Gettext translations
translations = babel.Translations.load(translations_data?translations_data:{}).install();
});