From: Thomas Heck Date: Thu, 7 Mar 2013 15:42:49 +0000 (+0100) Subject: JS-Übersetzung immer in HEAD laden X-Git-Tag: release-3.1.0beta1~546 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=440ad8d3e9fada111bf174d11081c910c361acef;p=kivitendo-erp.git JS-Übersetzung immer in HEAD laden --- diff --git a/SL/Layout/None.pm b/SL/Layout/None.pm index 0a2f6ca1a..971ef857a 100644 --- a/SL/Layout/None.pm +++ b/SL/Layout/None.pm @@ -29,7 +29,9 @@ sub use_javascript { js/jquery.js js/common.js js/namespace.js + js/kivi.js ), + 'js/locale/'. $::myconfig{countrycode} .'.js', $self->SUPER::use_javascript(@_); } diff --git a/js/kivi.js b/js/kivi.js index 77c78a2cc..bd169b231 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -1,25 +1,8 @@ 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; @@ -40,8 +23,9 @@ namespace("kivi", function(ns) { return text; }; - ns.initLocale = function(localeLang) { - ns._localeLang = localeLang; + ns.setupLocale = function(locale) { + ns._locale = locale; }; - }); + +kivi = namespace('kivi'); diff --git a/js/locale/de.js b/js/locale/de.js index 2c63c0851..ccba6a317 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -1,2 +1,2 @@ -{ -} +namespace("kivi").setupLocale({ +}); diff --git a/scripts/locales.pl b/scripts/locales.pl index d7b28a3db..b6665588a 100755 --- a/scripts/locales.pl +++ b/scripts/locales.pl @@ -143,13 +143,14 @@ generate_file( ); 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) { diff --git a/templates/webpages/layout/javascript_setup.js b/templates/webpages/layout/javascript_setup.js index bc4c5ef4e..dc516348c 100644 --- a/templates/webpages/layout/javascript_setup.js +++ b/templates/webpages/layout/javascript_setup.js @@ -1,7 +1,6 @@ [%- USE T8 %] $(function() { [% IF datefmt %] - namespace("kivi").initLocale("[% MYCONFIG.countrycode | html %]"); setupPoints('[% MYCONFIG.numberformat %]', '[% 'wrongformat' | $T8 %]'); setupDateFormat('[% MYCONFIG.dateformat %]', '[% 'Falsches Datumsformat!' | $T8 %]');