Revision 4d8ad1a5
Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt
scripts/locales.pl | ||
---|---|---|
37 | 37 |
my $dbupdir2 = "$basedir/sql/Pg-upgrade2"; |
38 | 38 |
my $menufile = "menu.ini"; |
39 | 39 |
my $submitsearch = qr/type\s*=\s*[\"\']?submit/i; |
40 |
our $self = {}; |
|
41 |
our $missing = {}; |
|
42 |
our @lost = (); |
|
40 | 43 |
|
41 | 44 |
my (%referenced_html_files, %locale, %htmllocale, %alllocales, %cached, %submit); |
42 | 45 |
my ($ALL_HEADER, $MISSING_HEADER, $LOST_HEADER); |
... | ... | |
64 | 67 |
return @files; |
65 | 68 |
} |
66 | 69 |
|
70 |
sub merge_texts { |
|
71 |
# overwrite existing entries with the ones from 'missing' |
|
72 |
$self->{texts}->{$_} = $missing->{$_} for grep { $missing->{$_} } keys %alllocales; |
|
73 |
|
|
74 |
# try to set missing entries from lost ones |
|
75 |
my %lost_by_text = map { ($_->{text} => $_->{translation}) } @lost; |
|
76 |
$self->{texts}->{$_} = $lost_by_text{$_} for grep { !$self->{texts}{$_} } keys %alllocales; |
|
77 |
} |
|
78 |
|
|
67 | 79 |
my @bindir_files = find_files($bindir); |
68 | 80 |
my @progfiles = map { m:^(.+)/([^/]+)$:; [ $2, $1 ] } grep { /\.pl$/ && !/_custom/ } @bindir_files; |
69 | 81 |
my @customfiles = grep /_custom/, @bindir_files; |
... | ... | |
89 | 101 |
my @dbplfiles2 = grep { /\.pl$/ } keys %dir_h; |
90 | 102 |
|
91 | 103 |
# slurp the translations in |
92 |
our $self = {}; |
|
93 |
our $missing = {}; |
|
94 |
our @missing = (); |
|
95 |
our @lost = (); |
|
96 |
|
|
97 | 104 |
if (-f "$locales_dir/all") { |
98 | 105 |
require "$locales_dir/all"; |
99 | 106 |
} |
... | ... | |
116 | 123 |
handle_file($_, $dbupdir2) for @dbplfiles2; |
117 | 124 |
scanmenu($_) for @menufiles; |
118 | 125 |
|
126 |
# merge entries to translate with entries from files 'missing' and 'lost' |
|
127 |
merge_texts(); |
|
128 |
|
|
119 | 129 |
# generate all |
120 | 130 |
generate_file( |
121 | 131 |
file => "$locales_dir/all", |
... | ... | |
124 | 134 |
data_sub => sub { _print_line($_, $self->{texts}{$_}, @_) for sort keys %alllocales }, |
125 | 135 |
); |
126 | 136 |
|
137 |
foreach my $text (keys %$missing) { |
|
138 |
if ($locale{$text} || $htmllocale{$text}) { |
|
139 |
unless ($self->{texts}{$text}) { |
|
140 |
$self->{texts}{$text} = $missing->{$text}; |
|
141 |
} |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
|
|
127 | 146 |
# calc and generate missing |
128 |
push @missing, grep { !$self->{texts}{$_} } sort keys %alllocales;
|
|
147 |
my @new_missing = grep { !$self->{texts}{$_} } sort keys %alllocales;
|
|
129 | 148 |
|
130 |
if (@missing) { |
|
149 |
if (@new_missing) {
|
|
131 | 150 |
generate_file( |
132 | 151 |
file => "$locales_dir/missing", |
133 | 152 |
header => $MISSING_HEADER, |
134 | 153 |
data_name => '$missing', |
135 |
data_sub => sub { _print_line($_, '', @_) for @missing }, |
|
154 |
data_sub => sub { _print_line($_, '', @_) for @new_missing },
|
|
136 | 155 |
); |
137 | 156 |
} |
138 | 157 |
|
... | ... | |
161 | 180 |
search_unused_htmlfiles() if $opt_c; |
162 | 181 |
|
163 | 182 |
my $count = scalar keys %alllocales; |
164 |
my $notext = scalar @missing; |
|
183 |
my $notext = scalar @new_missing;
|
|
165 | 184 |
my $per = sprintf("%.1f", ($count - $notext) / $count * 100); |
166 | 185 |
print "\n$trlanguage - ${per}%"; |
167 | 186 |
print " - $notext/$count missing" if $notext; |
... | ... | |
248 | 267 |
} |
249 | 268 |
|
250 | 269 |
$file =~ s/\.pl//; |
251 |
|
|
252 |
foreach my $text (keys %$missing) { |
|
253 |
if ($locale{$text} || $htmllocale{$text}) { |
|
254 |
unless ($self->{texts}{$text}) { |
|
255 |
$self->{texts}{$text} = $missing->{$text}; |
|
256 |
} |
|
257 |
} |
|
258 |
} |
|
259 | 270 |
} |
260 | 271 |
|
261 | 272 |
sub extract_text_between_parenthesis { |
Auch abrufbar als: Unified diff
Fehlende Übersetzungen aus "lost" nehmen, sofern dort vorhanden