X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=scripts%2Flocales.pl;h=3ae38a3b13d3c09926b3afbe039aad578f2e6c93;hb=4cb3a9081f02797bedd522b0f01539a0d9c0b3b3;hp=d8df86296e7da21ab518dfd641e35be351576176;hpb=7635f647ec7dcdef51684b21601ee0930ea2bc5b;p=kivitendo-erp.git diff --git a/scripts/locales.pl b/scripts/locales.pl index d8df86296..3ae38a3b1 100755 --- a/scripts/locales.pl +++ b/scripts/locales.pl @@ -43,6 +43,10 @@ our $self = {}; our $missing = {}; our @lost = (); +my %ignore_unused_templates = ( + map { $_ => 1 } qw(common/help_overlay.html ct/testpage.html generic/autocomplete.html oe/periodic_invoices_email.txt part/testpage.html t/render.html t/render.js) +); + my (%referenced_html_files, %locale, %htmllocale, %alllocales, %cached, %submit, %jslocale); my ($ALL_HEADER, $MISSING_HEADER, $LOST_HEADER); @@ -97,7 +101,7 @@ if ($opt_n) { } my @dbplfiles; -foreach my $sub_dir ("Pg-upgrade", "Pg-upgrade2", "Pg-upgrade2-auth") { +foreach my $sub_dir ("Pg-upgrade2", "Pg-upgrade2-auth") { my $dir = "$basedir/sql/$sub_dir"; tie %dir_h, 'IO::Dir', $dir; push @dbplfiles, map { [ $_, $dir ] } grep { /\.pl$/ } keys %dir_h; @@ -116,9 +120,6 @@ if (-f "$locales_dir/lost") { unlink "$locales_dir/lost"; } -my $charset = slurp("$locales_dir/charset") || 'utf-8'; -chomp $charset; - my %old_texts = %{ $self->{texts} || {} }; handle_file(@{ $_ }) for @progfiles; @@ -234,15 +235,20 @@ EOL sub parse_args { my ($help, $man); + my ($opt_no_c, $ignore_for_compatiblity); + GetOptions( 'no-custom-files' => \$opt_n, - 'check-files' => \$opt_c, + 'check-files' => \$ignore_for_compatiblity, + 'no-check-files' => \$opt_no_c, 'verbose' => \$opt_v, 'help' => \$help, 'man' => \$man, 'debug' => \$debug, ); + $opt_c = !$opt_no_c; + if ($help) { pod2usage(1); exit 0; @@ -440,8 +446,11 @@ sub scanfile { } } - my ($found) = / (?: locale->text | \b t8 ) \b .*? \(/x; - $postmatch = "$'"; + my $found; + if (/ (?: locale->text | \b t8 ) \b .*? \(/x) { + $found = 1; + $postmatch = "$'"; + } if ($found) { my $string; @@ -655,7 +664,7 @@ sub search_unused_htmlfiles { if (-d $entry) { push @unscanned_dirs, $entry; - } elsif (($entry =~ /_master.html$/) && -f $entry && !$referenced_html_files{$entry}) { + } elsif (!$ignore_unused_templates{strip_base($entry)} && -f $entry && !$referenced_html_files{$entry}) { print "W: unused HTML template: " . strip_base($entry) . "\n"; } @@ -705,10 +714,7 @@ sub generate_file { open my $fh, '>:encoding(utf8)', $file or die "$! : $file"; - $charset =~ s/\r?\n//g; - my $emacs_charset = lc $charset; - - print $fh "#!/usr/bin/perl\n# -*- coding: $emacs_charset; -*-\n# vim: fenc=$charset\n\nuse utf8;\n\n"; + print $fh "#!/usr/bin/perl\n# -*- coding: utf-8; -*-\n# vim: fenc=utf-8\n\nuse utf8;\n\n"; print $fh $header, "\n" if $header; print $fh "$data_name = $delim[0]\n" if $data_name;