]> wagnertech.de Git - mfinanz.git/blobdiff - scripts/locales.pl
Überreste von "gifi" entfernen (siehe 0daf163)
[mfinanz.git] / scripts / locales.pl
index 2bf10ec2cc97b7a3c8a907e6f6318332c92de9bd..b6665588abd2ce102ea897c490baa663758f1ba0 100755 (executable)
@@ -10,6 +10,7 @@ use utf8;
 use strict;
 
 use Carp;
+use Cwd;
 use Data::Dumper;
 use English;
 use File::Slurp qw(slurp);
@@ -29,6 +30,7 @@ my $debug  = 0;
 
 parse_args();
 
+my $locale;
 my $basedir      = "../..";
 my $locales_dir  = ".";
 my $bindir       = "$basedir/bin/mozilla";
@@ -37,6 +39,7 @@ 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     = {};
@@ -139,14 +142,15 @@ generate_file(
   data_sub  => sub { _print_line($_, $self->{texts}{$_}, @_) for sort keys %alllocales },
 );
 
-open(my $js_file, '>:encoding(utf8)', $locales_dir .'/js.js') || die;
-print $js_file '{'."\n";
+open(my $js_file, '>:encoding(utf8)', $javascript_output_dir .'/locale/'. $locale .'.js') || die;
+print $js_file 'namespace("kivi").setupLocale({';
 my $first_entry = 1;
 for my $key (sort(keys(%jslocale))) {
-  print $js_file (!$first_entry ? ',' : '') . _double_quote($key) .':'. _double_quote($self->{texts}{$key}) ."\n";
+  print $js_file ((!$first_entry ? ',' : '') ."\n". _double_quote($key) .':'. _double_quote($self->{texts}{$key}));
   $first_entry = 0;
 }
-print $js_file '}'."\n";
+print $js_file ("\n");
+print $js_file ('});'."\n");
 close($js_file);
 
   foreach my $text (keys %$missing) {
@@ -248,6 +252,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;
     }
@@ -262,6 +269,9 @@ sub parse_args {
       .   "and no locale directory name was given.\n";
     exit 1;
   }
+
+  $locale ||=  (grep { $_ } split m:/:, getcwd())[-1];
+  $locale   =~ s/\.+$//;
 }
 
 sub handle_file {
@@ -373,6 +383,13 @@ sub scanfile {
         $cached{$file}{scannosubs}{"../../SL/${module}.pm"} = 1;
       }
 
+      # Some calls to render() are split over multiple lines. Deal
+      # with that.
+      while (/(?:parse_html_template2?|render)\s*\( *$/) {
+        $_ .= <$fh>;
+        chomp;
+      }
+
       # is this a template call?
       if (/(?:parse_html_template2?|render)\s*\(\s*[\"\']([\w\/]+)\s*[\"\']/) {
         my $new_file_base = "$basedir/templates/webpages/$1.";
@@ -519,9 +536,11 @@ sub scanhtmlfile {
 
       while ($line =~ m/\[\%[^\w]*(\w+)\.\w+\(/g) {
         my $plugin = $1;
-        $plugins{needed}->{$plugin} = 1 if (first { $_ eq $plugin } qw(HTML LxERP JavaScript MultiColumnIterator L));
+        $plugins{needed}->{$plugin} = 1 if (first { $_ eq $plugin } qw(HTML LxERP JavaScript JSON L P));
       }
 
+      $plugins{needed}->{T8} = 1 if $line =~ m/\[\%.*\|.*\$T8/;
+
       while ($line =~ m/(?:             # Start von Variante 1: LxERP.t8('...'); ohne darumliegende [% ... %]-Tags
                           (LxERP\.t8)\( #   LxERP.t8(                             ::Parameter $1::
                           ([\'\"])      #   Anfang des zu übersetzenden Strings   ::Parameter $2::