X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=scripts%2Flocales.pl;h=24b06877f0690577fc1468985014ca513432174a;hb=f9676efea9ccfa01df2a57dca9c45cc8fde0d09e;hp=dd7c4ca376b721ec90ed6855df00ddc364e8c7f9;hpb=faeeee8ace169bbaf736e44abc271cf472ccbb26;p=kivitendo-erp.git diff --git a/scripts/locales.pl b/scripts/locales.pl index dd7c4ca37..24b06877f 100755 --- a/scripts/locales.pl +++ b/scripts/locales.pl @@ -23,13 +23,12 @@ $OUTPUT_AUTOFLUSH = 1; my $opt_v = 0; my $opt_n = 0; my $opt_c = 0; -my $lang; my $debug = 0; parse_args(); -my $basedir = "."; -my $locales_dir = "$basedir/locale/$lang"; +my $basedir = "../.."; +my $locales_dir = "."; my $bindir = "$basedir/bin/mozilla"; my $dbupdir = "$basedir/sql/Pg-upgrade"; my $dbupdir2 = "$basedir/sql/Pg-upgrade2"; @@ -86,6 +85,9 @@ if (-f "$locales_dir/lost") { unlink "$locales_dir/lost"; } +my $charset = slurp("$locales_dir/charset") || 'utf-8'; +chomp $charset; + my %old_texts = %{ $self->{texts} || {} }; map({ handle_file($_, $bindir); } @progfiles); @@ -126,7 +128,7 @@ if (scalar @lost) { delim => '()', data_name => '@lost', data_sub => sub { - _print_line($_->{text}, $_->{translation}, @_, template => " { 'text' => %s, 'translation' => %s },") for @lost; + _print_line($_->{text}, $_->{translation}, @_, template => " { 'text' => %s, 'translation' => %s },\n") for @lost; }, ); } @@ -158,8 +160,8 @@ EOL # add the missing texts and run locales.pl to rebuild EOL $LOST_HEADER = <', $file or die "$! : $file"; - print $fh "#!/usr/bin/perl\n\n"; + print $fh "#!/usr/bin/perl\n# -*- coding: $charset; -*-\n# vim: fenc=$charset\n\n"; print $fh $header, "\n" if $header; print $fh "$data_name = $delim[0]\n" if $data_name; @@ -591,6 +611,11 @@ sub generate_file { close $fh; } +sub slurp { + my $file = shift; + do { local ( @ARGV, $/ ) = $file; <> } +} + __END__ =head1 NAME @@ -599,7 +624,7 @@ locales.pl - Collect strings for translation in Lx-Office =head1 SYNOPSIS -locales.pl [options] +locales.pl [options] lang_code Options: -n, --no-custom-files Do not process files whose name contains "_" @@ -630,7 +655,6 @@ Be more verbose. =head1 DESCRIPTION This script collects strings from Perl files, the menu.ini file and -HTML templates and puts them into the file "all" for translation. It -also distributes those translations back to the individual files. +HTML templates and puts them into the file "all" for translation. =cut