diff options
author | Christoph Berg | 2015-07-16 10:39:57 +0000 |
---|---|---|
committer | Christoph Berg | 2015-07-16 11:45:37 +0000 |
commit | eda8e72855eb9131b4278de4a377964fa43873b6 (patch) | |
tree | 84f44b6c1c9de204ed90bd3a68ed85e8926b4fd6 | |
parent | 404d6ebf32411451f52a34092877c0f1d90354a4 (diff) |
set_translations.pl: Write output for all known languages
set_translations.pl only wrote output for languages seen in .po files,
dropping other previously known languages.
Also, fix output to honor the current indentation style (no tabs). In
order to change the current formatting as little as possible, set the
minimal output key output width to 14, and no not append a space after
'key' ('checkcluster-nomrtg' is otherwise too long).
-rwxr-xr-x | set_translations.pl | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/set_translations.pl b/set_translations.pl index 1b1db000d..a4ab87bef 100755 --- a/set_translations.pl +++ b/set_translations.pl @@ -69,7 +69,7 @@ for my $line (@lines) { } ## A message - if ($line =~ /^(\s*)'([\w\-]+)'\s+=> (qq?)\{(.+?)}[,.](.*)/) { + if ($line =~ /^(\s*)'([\w\-]+)'\s*=> (qq?)\{(.+?)}[,.](.*)/) { my ($space,$msg,$quote,$value,$comment) = (length $1 ? 1 : 0, $2, $3, $4, $5); $msg{$lang}{$msg} = [$space,$value,$quote,$comment]; if ($lang eq 'en' and $msg =~ /\-po\d*$/) { @@ -90,7 +90,8 @@ for my $ll (sort keys %po) { for my $tr (sort keys %trans) { my $val = $trans{$tr}; if ($mm =~ /^$val/) { - $nn =~ s/(.+?)\s*\%.*/$1/; + $nn =~ s/(.+?)\s*\%.*/$1/; # remove everything from % on + print "$tr/$ll: $val -> $nn\n"; length $nn and $msg{$ll}{$tr} = [1,$nn,'q','']; } } @@ -106,24 +107,27 @@ for my $line (@lines) { last if $line =~ /^our \%msg/; } +my %all_langs = map { $_ => 1} (keys %msg, keys %po); + ## Add in the translated sections, with new info as needed for my $m (sort { ## English goes first, as the base class return -1 if $a eq 'en'; return 1 if $b eq 'en'; - ## French goes next, as the next-most-completed language + ## Then the fully translated languages + return -1 if $a eq 'es'; return 1 if $b eq 'es'; return -1 if $a eq 'fr'; return 1 if $b eq 'fr'; ## Everything else is alphabetical return $a cmp $b -} keys %po) { +} keys %all_langs) { print {$fh} qq!'$m' => {\n!; - my $size = 1; + my $size = 14; # length of "checkpoint-po" + 1 for my $msg (keys %{$msg{$m}}) { $size = length($msg) if length($msg) > $size; } for my $mm (sort keys %{$msg{$m}}) { - printf {$fh} "%s%-*s => %s{%s},%s\n", - $msg{$m}{$mm}->[0] ? "\t" : '', + printf {$fh} "%s%-*s=> %s{%s},%s\n", + $msg{$m}{$mm}->[0] ? " " : '', 2+$size, qq{'$mm'}, $msg{$m}{$mm}->[2], @@ -183,7 +187,7 @@ sub process_po_files { $isid = 0; } elsif (/^"(.*)"/) { - $isid ? ($id .= $1) : ($po{$lang}{$id} .= $1); + $isid ? ($id .= $1) : ($panda->{$lang}{$id} .= $1); } } close $fh or warn qq{Could not close "$pofile" $!\n}; |