From: Thomas Heck Date: Wed, 27 Feb 2013 13:06:27 +0000 (+0100) Subject: scripts/locales.pl um JS-Übersetzung erweitert X-Git-Tag: release-3.1.0beta1~554^2~1^2~8 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=224291ddfd1633e2e3a47632cca24c1039fcb105;p=kivitendo-erp.git scripts/locales.pl um JS-Übersetzung erweitert --- diff --git a/SL/Layout/None.pm b/SL/Layout/None.pm index 50ab2f854..25ea9161a 100644 --- a/SL/Layout/None.pm +++ b/SL/Layout/None.pm @@ -13,6 +13,7 @@ sub use_javascript { qw( js/jquery.js js/common.js + js/namespace.js ), $self->SUPER::use_javascript(@_); } diff --git a/js/kivi.js b/js/kivi.js new file mode 100644 index 000000000..db9904b53 --- /dev/null +++ b/js/kivi.js @@ -0,0 +1,48 @@ +namespace("kivi", function(ns) { + + ns._localeLang = false; + ns._locales = {}; + + ns.t8 = function(text, params) { + if( ns._localeLang ) { + if( !ns._locales[ns._localeLang] ) { + jQuery.ajax({ + url: "locale/"+ ns._localeLang +"/js.js", + async: false, + dataType: "json", + success: function(res) { + ns._locales[ns._localeLang] = res; + }, + error: function(xhr, textStatus, errorThrown) { + alert(textStatus +": "+ errorThrown); + }, + }); + } + + text = ns._locales[ns._localeLang][text] || text; + } + + if( Object.prototype.toString.call( params ) === '[object Array]' ) { + var len = params.length; + + for(var i=0; i sub { _print_line($_, $self->{texts}{$_}, @_) for sort keys %alllocales }, ); +open(my $js_file, '>:encoding(utf8)', $locales_dir .'/js.js') || die; +print $js_file '{'."\n"; +my $first_entry = 1; +for my $key (sort(keys(%jslocale))) { + print $js_file (!$first_entry ? ',' : '') . _double_quote($key) .':'. _double_quote($self->{texts}{$key}) ."\n"; + $first_entry = 0; +} +print $js_file '}'."\n"; +close($js_file); + foreach my $text (keys %$missing) { if ($locale{$text} || $htmllocale{$text}) { unless ($self->{texts}{$text}) { @@ -385,7 +400,7 @@ sub scanfile { while ($rc) { if (/Locale/) { unless (/^use /) { - my ($null, $country) = split /,/; + my ($null, $country) = split(/,/); $country =~ s/^ +[\"\']//; $country =~ s/[\"\'].*//; } @@ -577,6 +592,31 @@ sub scanhtmlfile { $referenced_html_files{$_} = 1 for keys %{$cached{$file}{scanh}}; } +sub scan_javascript_file { + my ($file) = @_; + + open(my $fh, $file) || die('can not open file: '. $file); + + while( my $line = readline($fh) ) { + while( $line =~ m/ + kivi.t8 + \s* + \( + \s* + ([\'\"]) + (.*?) + (?