Skip to content

Commit eda8e72

Browse files
committed
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).
1 parent 404d6eb commit eda8e72

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

set_translations.pl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
}
7070

7171
## A message
72-
if ($line =~ /^(\s*)'([\w\-]+)'\s+=> (qq?)\{(.+?)}[,.](.*)/) {
72+
if ($line =~ /^(\s*)'([\w\-]+)'\s*=> (qq?)\{(.+?)}[,.](.*)/) {
7373
my ($space,$msg,$quote,$value,$comment) = (length $1 ? 1 : 0, $2, $3, $4, $5);
7474
$msg{$lang}{$msg} = [$space,$value,$quote,$comment];
7575
if ($lang eq 'en' and $msg =~ /\-po\d*$/) {
@@ -90,7 +90,8 @@
9090
for my $tr (sort keys %trans) {
9191
my $val = $trans{$tr};
9292
if ($mm =~ /^$val/) {
93-
$nn =~ s/(.+?)\s*\%.*/$1/;
93+
$nn =~ s/(.+?)\s*\%.*/$1/; # remove everything from % on
94+
print "$tr/$ll: $val -> $nn\n";
9495
length $nn and $msg{$ll}{$tr} = [1,$nn,'q',''];
9596
}
9697
}
@@ -106,24 +107,27 @@
106107
last if $line =~ /^our \%msg/;
107108
}
108109

110+
my %all_langs = map { $_ => 1} (keys %msg, keys %po);
111+
109112
## Add in the translated sections, with new info as needed
110113
for my $m (sort {
111114
## English goes first, as the base class
112115
return -1 if $a eq 'en'; return 1 if $b eq 'en';
113-
## French goes next, as the next-most-completed language
116+
## Then the fully translated languages
117+
return -1 if $a eq 'es'; return 1 if $b eq 'es';
114118
return -1 if $a eq 'fr'; return 1 if $b eq 'fr';
115119
## Everything else is alphabetical
116120
return $a cmp $b
117-
} keys %po) {
121+
} keys %all_langs) {
118122
print {$fh} qq!'$m' => {\n!;
119-
my $size = 1;
123+
my $size = 14; # length of "checkpoint-po" + 1
120124
for my $msg (keys %{$msg{$m}}) {
121125
$size = length($msg) if length($msg) > $size;
122126
}
123127

124128
for my $mm (sort keys %{$msg{$m}}) {
125-
printf {$fh} "%s%-*s => %s{%s},%s\n",
126-
$msg{$m}{$mm}->[0] ? "\t" : '',
129+
printf {$fh} "%s%-*s=> %s{%s},%s\n",
130+
$msg{$m}{$mm}->[0] ? " " : '',
127131
2+$size,
128132
qq{'$mm'},
129133
$msg{$m}{$mm}->[2],
@@ -183,7 +187,7 @@ sub process_po_files {
183187
$isid = 0;
184188
}
185189
elsif (/^"(.*)"/) {
186-
$isid ? ($id .= $1) : ($po{$lang}{$id} .= $1);
190+
$isid ? ($id .= $1) : ($panda->{$lang}{$id} .= $1);
187191
}
188192
}
189193
close $fh or warn qq{Could not close "$pofile" $!\n};

0 commit comments

Comments
 (0)