namespace("kivi", function(ns) {
-
- ns._localeLang = false;
- ns._locales = {};
+ ns._locale = {};
ns.t8 = function(text, params) {
- if( ns._localeLang ) {
- if( !ns._locales[ns._localeLang] ) {
- ns._locales[ns._localeLang] = {};
-
- jQuery.ajax({
- url: "js/locale/"+ ns._localeLang +".js",
- async: false,
- dataType: "json",
- success: function(res) {
- ns._locales[ns._localeLang] = res;
- },
- });
- }
-
- text = ns._locales[ns._localeLang][text] || text;
- }
+ var text = ns._locale[text] || text;
if( Object.prototype.toString.call( params ) === '[object Array]' ) {
var len = params.length;
return text;
};
- ns.initLocale = function(localeLang) {
- ns._localeLang = localeLang;
+ ns.setupLocale = function(locale) {
+ ns._locale = locale;
};
-
});
+
+kivi = namespace('kivi');
);
open(my $js_file, '>:encoding(utf8)', $javascript_output_dir .'/locale/'. $locale .'.js') || die;
-print $js_file '{';
+print $js_file 'namespace("kivi").setupLocale({';
my $first_entry = 1;
for my $key (sort(keys(%jslocale))) {
print $js_file ((!$first_entry ? ',' : '') ."\n". _double_quote($key) .':'. _double_quote($self->{texts}{$key}));
$first_entry = 0;
}
-print $js_file ("\n".'}'."\n");
+print $js_file ("\n");
+print $js_file ('});'."\n");
close($js_file);
foreach my $text (keys %$missing) {
[%- USE T8 %]
$(function() {
[% IF datefmt %]
- namespace("kivi").initLocale("[% MYCONFIG.countrycode | html %]");
setupPoints('[% MYCONFIG.numberformat %]', '[% 'wrongformat' | $T8 %]');
setupDateFormat('[% MYCONFIG.dateformat %]', '[% 'Falsches Datumsformat!' | $T8 %]');