X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=locale%2Fde%2Flocales.pl;h=6fd6e80e1acc4b07cc0de89ef9f2a34fc6a200dd;hb=689525d261aa6f237c1ff2e0dc3bbf962fce2761;hp=da86e02499a466d426dcfb9478d84c126a29c6c8;hpb=a507676c62c769abf01dcd9a2f91cfa1b5dd3841;p=kivitendo-erp.git diff --git a/locale/de/locales.pl b/locale/de/locales.pl index da86e0249..6fd6e80e1 100755 --- a/locale/de/locales.pl +++ b/locale/de/locales.pl @@ -10,6 +10,8 @@ use POSIX; use FileHandle; use Data::Dumper; +use List::Util qw(first); + $| = 1; $basedir = "../.."; @@ -62,6 +64,8 @@ if (-f 'all') { require "all"; } +my %old_texts = %{ $self->{texts} }; + # Read HTML templates. #%htmllocale = (); #@htmltemplates = <../../templates/webpages/*/*_master.html>; @@ -249,6 +253,38 @@ $missing = { } +@lost = (); + +if (-f "lost") { + require "lost"; + unlink "lost"; +} + +while (($text, $translation) = each %old_texts) { + next if ($alllocales{$text}); + + push @lost, { 'text' => $text, 'translation' => $translation }; +} + +if (scalar @lost) { + splice @lost, 0, (scalar @lost - 50) if (scalar @lost > 50); + + open FH, ">lost"; + print FH "#!/usr/bin/perl\n\n" . + "# The last 50 texts that have been removed.\n" . + "# This file will be auto-generated by locales.pl. Do not edit it.\n\n" . + "\@lost = (\n"; + + foreach $entry (@lost) { + $entry->{text} =~ s/\'/\\\'/; + $entry->{translation} =~ s/\'/\\\'/; + print FH " { 'text' => '$entry->{text}', 'translation' => '$entry->{translation}' },\n"; + } + + print FH ");\n\n1;\n"; + close FH; +} + open(FH, "LANGUAGE"); @language = ; close(FH); @@ -325,6 +361,9 @@ sub scanfile { my $dont_include_subs = shift; my $scanned_files = shift; + # sanitize file + $file =~ s=/+=/=g; + $scanned_files = {} unless ($scanned_files); return if ($scanned_files->{$file}); $scanned_files->{$file} = 1; @@ -481,9 +520,10 @@ sub scanmenu { sub scanhtmlfile { local *IN; - + if (!defined $cached{$_[0]}) { - + my %plugins = ( 'loaded' => { }, 'needed' => { } ); + open(IN, $_[0]) || die $_[0]; my $copying = 0; @@ -492,6 +532,15 @@ sub scanhtmlfile { while (my $line = ) { chomp($line); + while ($line =~ m/\[\%[^\w]*use[^\w]+(\w+)[^\w]*?\%\]/gi) { + $plugins{loaded}->{$1} = 1; + } + + while ($line =~ m/\[\%[^\w]*(\w+)\.\w+\(/g) { + my $plugin = $1; + $plugins{needed}->{$plugin} = 1 if (first { $_ eq $plugin } qw(HTML LxERP JavaScript MultiColumnIterator)); + } + while ("" ne $line) { if (!$copying) { if ($line =~ m||i) { @@ -532,6 +581,12 @@ sub scanhtmlfile { } close(IN); + + foreach my $plugin (keys %{ $plugins{needed} }) { + next if ($plugins{loaded}->{$plugin}); + print "E: " . strip_base($_[0]) . " requires the Template plugin '$plugin', but is not loaded with '[\% USE $plugin \%]'.\n"; + } + &converthtmlfile($_[0]); } @@ -640,8 +695,10 @@ sub search_translated_htmlfiles_wo_master { } sub strip_base { - $_[0] =~ s|^../../||; - $_[0] =~ s|templates/webpages/||; + my $s = "$_[0]"; # Create a copy of the string. + + $s =~ s|^../../||; + $s =~ s|templates/webpages/||; - return $_[0]; + return $s; }