Doku: Test-Doku aus t/README in die Haupt-Doku überführt & erweitert
[kivitendo-erp.git] / scripts / locales.pl
index ff2638b..f526416 100755 (executable)
@@ -31,6 +31,7 @@ parse_args();
 my $basedir      = "../..";
 my $locales_dir  = ".";
 my $bindir       = "$basedir/bin/mozilla";
+my @progdirs     = ( "$basedir/SL" );
 my $dbupdir      = "$basedir/sql/Pg-upgrade";
 my $dbupdir2     = "$basedir/sql/Pg-upgrade2";
 my $menufile     = "menu.ini";
@@ -41,11 +42,38 @@ my ($ALL_HEADER, $MISSING_HEADER, $LOST_HEADER);
 
 init();
 
-opendir DIR, "$bindir" or die "$!";
-my @progfiles = grep { /\.pl$/ && !/(_custom|^\.)/ } readdir DIR;
-seekdir DIR, 0;
-my @customfiles = grep /_custom/, readdir DIR;
-closedir DIR;
+sub find_files {
+  my ($dir_name, $files) = @_;
+
+  $files ||= [];
+
+  my @dirs_to_check;
+
+  opendir my $dir, $dir_name or die "$! $dir_name";
+
+  foreach my $name (readdir $dir) {
+    next if $name eq '.' || $name eq '..';
+
+    my $full_name = "${dir_name}/${name}";
+    if (-d $full_name) {
+      push @dirs_to_check, $full_name;
+    } else {
+      push @{ $files }, $full_name;
+    }
+  }
+
+  closedir $dir;
+
+  map { find_files($_, $files) } @dirs_to_check;
+
+  return @{ $files };
+}
+
+my @bindir_files = find_files($bindir);
+my @progfiles    = map { m:^(.+)/([^/]+)$:; [ $2, $1 ]  } grep { /\.pl$/ && !/_custom/ } @bindir_files;
+my @customfiles  = grep /_custom/, @bindir_files;
+
+push @progfiles, map { m:^(.+)/([^/]+)$:; [ $2, $1 ] } grep { /\.pm$/ } map { find_files($_) } @progdirs;
 
 # put customized files into @customfiles
 my @menufiles;
@@ -91,7 +119,7 @@ chomp $charset;
 
 my %old_texts = %{ $self->{texts} || {} };
 
-map({ handle_file($_, $bindir); } @progfiles);
+map({ handle_file(@{ $_ }); } @progfiles);
 map({ handle_file($_, $dbupdir); } @dbplfiles);
 map({ handle_file($_, $dbupdir2); } @dbplfiles2);
 
@@ -226,20 +254,6 @@ sub handle_file {
     }
   }
 
-  # if this is the menu.pl file
-  if ($file eq 'menu.pl') {
-    foreach my $item (@menufiles) {
-      &scanmenu("$basedir/$item");
-    }
-  }
-
-  if ($file eq 'menunew.pl') {
-    foreach my $item (@menufiles) {
-      &scanmenu("$basedir/$item");
-      print "." if $opt_v;
-    }
-  }
-
   $file =~ s/\.pl//;
 
   foreach my $text (keys %$missing) {
@@ -283,11 +297,11 @@ sub extract_text_between_parenthesis {
 
     } else {
       if ($quote_next) {
+        $text .= '\\' unless $cur_char eq "'";
         $text .= $cur_char;
         $quote_next = 0;
 
       } elsif ($cur_char eq '\\') {
-        $text .= $cur_char;
         $quote_next = 1;
 
       } elsif ($cur_char eq $inside_string) {
@@ -324,6 +338,8 @@ sub scanfile {
     my ($is_submit, $line_no, $sub_line_no) = (0, 0, 0);
 
     while (<$fh>) {
+      last if /^\s*__END__/;
+
       $line_no++;
 
       # is this another file
@@ -339,7 +355,7 @@ sub scanfile {
       }
 
       # is this a template call?
-      if (/parse_html_template2?\s*\(\s*[\"\']([\w\/]+)\s*[\"\']/) {
+      if (/(?:parse_html_template2?|render)\s*\(\s*[\"\']([\w\/]+)\s*[\"\']/) {
         my $newfile = "$basedir/templates/webpages/$1.html";
         if (/parse_html_template2/) {
           print "E: " . strip_base($file) . " is still using 'parse_html_template2' for " . strip_base($newfile) . ".\n";
@@ -374,7 +390,7 @@ sub scanfile {
           }
         }
 
-        my ($found) = /locale->text.*?\(/;
+        my ($found) = / (?: locale->text | \b t8 ) \b .*? \(/x;
         $postmatch = "$'";
 
         if ($found) {