From: Thomas Heck Date: Wed, 6 Mar 2013 15:43:59 +0000 (+0100) Subject: Merge branch 'master' into dev X-Git-Tag: release-3.1.0beta1~554^2~1^2~2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=49556f01cfe6a395cf5554e1a00dc61d6da0493e;hp=baf1e8957f7f56fb46e849fff966e3490726097b;p=kivitendo-erp.git Merge branch 'master' into dev --- diff --git a/SL/Layout/None.pm b/SL/Layout/None.pm index c3708bffc..0a2f6ca1a 100644 --- a/SL/Layout/None.pm +++ b/SL/Layout/None.pm @@ -28,6 +28,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{texts} = { 'CSV import: projects' => 'CSV-Import: Projekte', 'CSV import: shipping addresses' => 'CSV-Import: Lieferadressen', 'Calculate' => 'Berechnen', - 'Calendar' => 'Kalender', 'Can not create that quantity with current stock' => 'Diese Anzahl kann mit dem gegenwärtigen Lagerbestand nicht hergestellt werden.', 'Cancel' => 'Abbrechen', 'Cancel Accounts Payables Transaction' => 'Kreditorenbuchung stornieren', diff --git a/scripts/locales.pl b/scripts/locales.pl index baf0dc661..b6cccf118 100755 --- a/scripts/locales.pl +++ b/scripts/locales.pl @@ -29,6 +29,7 @@ my $debug = 0; parse_args(); +my $locale; my $basedir = "../.."; my $locales_dir = "."; my $bindir = "$basedir/bin/mozilla"; @@ -36,12 +37,14 @@ my @progdirs = ( "$basedir/SL" ); my $dbupdir = "$basedir/sql/Pg-upgrade"; my $dbupdir2 = "$basedir/sql/Pg-upgrade2"; my $menufile = "menu.ini"; +my @javascript_dirs = ($basedir .'/js', $basedir .'/templates/webpages'); +my $javascript_output_dir = $basedir .'/js'; my $submitsearch = qr/type\s*=\s*[\"\']?submit/i; our $self = {}; our $missing = {}; our @lost = (); -my (%referenced_html_files, %locale, %htmllocale, %alllocales, %cached, %submit); +my (%referenced_html_files, %locale, %htmllocale, %alllocales, %cached, %submit, %jslocale); my ($ALL_HEADER, $MISSING_HEADER, $LOST_HEADER); init(); @@ -123,6 +126,10 @@ handle_file($_, $dbupdir) for @dbplfiles; handle_file($_, $dbupdir2) for @dbplfiles2; scanmenu($_) for @menufiles; +for my $file_name (map({find_files($_)} @javascript_dirs)) { + scan_javascript_file($file_name); +} + # merge entries to translate with entries from files 'missing' and 'lost' merge_texts(); @@ -134,6 +141,16 @@ generate_file( data_sub => sub { _print_line($_, $self->{texts}{$_}, @_) for sort keys %alllocales }, ); +open(my $js_file, '>:encoding(utf8)', $javascript_output_dir .'/locale/'. $locale .'js') || die; +print $js_file '{'; +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"); +close($js_file); + foreach my $text (keys %$missing) { if ($locale{$text} || $htmllocale{$text}) { unless ($self->{texts}{$text}) { @@ -233,6 +250,9 @@ sub parse_args { my $ok = 0; foreach my $dir ("../locale/$arg", "locale/$arg", "../$arg", $arg) { next unless -d $dir && -f "$dir/all" && -f "$dir/LANGUAGE"; + + $locale = $arg; + $ok = chdir $dir; last; } @@ -392,7 +412,7 @@ sub scanfile { while ($rc) { if (/Locale/) { unless (/^use /) { - my ($null, $country) = split /,/; + my ($null, $country) = split(/,/); $country =~ s/^ +[\"\']//; $country =~ s/[\"\'].*//; } @@ -586,6 +606,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* + ([\'\"]) + (.*?) + (?