Revision 860f3274
Von Moritz Bunkus vor mehr als 19 Jahren hinzugefügt
locale/de/locales.pl | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use FileHandle; |
6 | 6 |
|
7 |
|
|
8 |
$basedir = "../.."; |
|
9 |
$bindir = "$basedir/bin/mozilla"; |
|
7 |
$basedir = "../.."; |
|
8 |
$bindir = "$basedir/bin/mozilla"; |
|
10 | 9 |
$menufile = "menu.ini"; |
11 | 10 |
|
12 | 11 |
foreach $item (@ARGV) { |
... | ... | |
32 | 31 |
unshift @menufiles, $menufile; |
33 | 32 |
} |
34 | 33 |
|
35 |
|
|
36 | 34 |
# slurp the translations in |
37 | 35 |
if (-f 'all') { |
38 | 36 |
require "all"; |
39 | 37 |
} |
40 | 38 |
|
41 |
|
|
42 | 39 |
foreach $file (@progfiles) { |
43 |
|
|
40 |
|
|
44 | 41 |
%locale = (); |
45 | 42 |
%submit = (); |
46 |
%subrt = (); |
|
47 |
|
|
43 |
%subrt = ();
|
|
44 |
|
|
48 | 45 |
&scanfile("$bindir/$file"); |
49 | 46 |
|
50 | 47 |
# scan custom_{module}.pl or {login}_{module}.pl files |
51 | 48 |
foreach $customfile (@customfiles) { |
52 | 49 |
if ($customfile =~ /_$file/) { |
53 | 50 |
if (-f "$bindir/$customfile") { |
54 |
&scanfile("$bindir/$customfile");
|
|
51 |
&scanfile("$bindir/$customfile");
|
|
55 | 52 |
} |
56 | 53 |
} |
57 | 54 |
} |
58 |
|
|
55 |
|
|
59 | 56 |
# if this is the menu.pl file |
60 | 57 |
if ($file eq 'menu.pl') { |
61 | 58 |
foreach $item (@menufiles) { |
... | ... | |
71 | 68 |
|
72 | 69 |
$file =~ s/\.pl//; |
73 | 70 |
|
74 |
|
|
75 | 71 |
eval { require 'missing'; }; |
76 | 72 |
unlink 'missing'; |
77 | 73 |
|
78 | 74 |
foreach $text (keys %$missing) { |
79 | 75 |
if ($locale{$text}) { |
80 | 76 |
unless ($self{texts}{$text}) { |
81 |
$self{texts}{$text} = $missing->{$text};
|
|
77 |
$self{texts}{$text} = $missing->{$text};
|
|
82 | 78 |
} |
83 | 79 |
} |
84 | 80 |
} |
85 | 81 |
|
86 |
|
|
87 | 82 |
open FH, ">$file" or die "$! : $file"; |
88 | 83 |
|
89 | 84 |
print FH q|$self{texts} = { |
... | ... | |
101 | 96 |
$keytext = $key; |
102 | 97 |
$keytext =~ s/'/\\'/g; |
103 | 98 |
$keytext =~ s/\\$/\\\\/; |
104 |
|
|
105 |
print FH qq| '$keytext'|.(' ' x (27-length($keytext))).qq| => '$text',\n|; |
|
99 |
|
|
100 |
print FH qq| '$keytext'| |
|
101 |
. (' ' x (27 - length($keytext))) |
|
102 |
. qq| => '$text',\n|; |
|
106 | 103 |
} |
107 | 104 |
|
108 | 105 |
print FH q|}; |
109 | 106 |
|
110 | 107 |
$self{subs} = { |
111 | 108 |
|; |
112 |
|
|
109 |
|
|
113 | 110 |
foreach $key (sort keys %subrt) { |
114 | 111 |
$text = $key; |
115 | 112 |
$text =~ s/'/\\'/g; |
116 | 113 |
$text =~ s/\\$/\\\\/; |
117 |
print FH qq| '$text'|.(' ' x (27-length($text))).qq| => '$text',\n|;
|
|
114 |
print FH qq| '$text'| . (' ' x (27 - length($text))) . qq| => '$text',\n|;
|
|
118 | 115 |
} |
119 | 116 |
|
120 | 117 |
foreach $key (sort keys %submit) { |
... | ... | |
126 | 123 |
$english_sub =~ s/'/\\'/g; |
127 | 124 |
$english_sub =~ s/\\$/\\\\/; |
128 | 125 |
$english_sub = lc $key; |
129 |
|
|
126 |
|
|
130 | 127 |
$translated_sub = lc $text; |
131 |
$english_sub =~ s/( |-|,)/_/g; |
|
128 |
$english_sub =~ s/( |-|,)/_/g;
|
|
132 | 129 |
$translated_sub =~ s/( |-|,)/_/g; |
133 |
print FH qq| '$translated_sub'|.(' ' x (27-length($translated_sub))).qq| => '$english_sub',\n|; |
|
130 |
print FH qq| '$translated_sub'| |
|
131 |
. (' ' x (27 - length($translated_sub))) |
|
132 |
. qq| => '$english_sub',\n|; |
|
134 | 133 |
} |
135 |
|
|
134 |
|
|
136 | 135 |
print FH q|}; |
137 | 136 |
|
138 | 137 |
1; |
... | ... | |
141 | 140 |
close FH; |
142 | 141 |
} |
143 | 142 |
|
144 |
|
|
145 | 143 |
# now print out all |
146 | 144 |
|
147 | 145 |
open FH, ">all" or die "$! : all"; |
... | ... | |
154 | 152 |
$self{texts} = { |
155 | 153 |
|; |
156 | 154 |
|
157 |
|
|
158 | 155 |
foreach $key (sort keys %alllocales) { |
159 | 156 |
$text = $self{texts}{$key}; |
160 | 157 |
|
161 | 158 |
$count++; |
162 |
|
|
159 |
|
|
163 | 160 |
$text =~ s/'/\\'/g; |
164 | 161 |
$text =~ s/\\$/\\\\/; |
165 |
$key =~ s/'/\\'/g; |
|
166 |
$key =~ s/\\$/\\\\/; |
|
162 |
$key =~ s/'/\\'/g;
|
|
163 |
$key =~ s/\\$/\\\\/;
|
|
167 | 164 |
|
168 | 165 |
unless ($text) { |
169 | 166 |
$notext++; |
170 | 167 |
push @missing, $key; |
171 | 168 |
} |
172 | 169 |
|
173 |
print FH qq| '$key'|.(' ' x (27-length($key))).qq| => '$text',\n|;
|
|
170 |
print FH qq| '$key'| . (' ' x (27 - length($key))) . qq| => '$text',\n|;
|
|
174 | 171 |
|
175 | 172 |
} |
176 | 173 |
|
... | ... | |
181 | 178 |
|
182 | 179 |
close FH; |
183 | 180 |
|
184 |
|
|
185 | 181 |
if (@missing) { |
186 | 182 |
open FH, ">missing" or die "$! : missing"; |
187 | 183 |
|
... | ... | |
191 | 187 |
|; |
192 | 188 |
|
193 | 189 |
foreach $text (@missing) { |
194 |
print FH qq| '$text'|.(' ' x (27-length($text))).qq| => '',\n|;
|
|
190 |
print FH qq| '$text'| . (' ' x (27 - length($text))) . qq| => '',\n|;
|
|
195 | 191 |
} |
196 | 192 |
|
197 | 193 |
print FH q|}; |
... | ... | |
200 | 196 |
|; |
201 | 197 |
|
202 | 198 |
close FH; |
203 |
|
|
199 |
|
|
204 | 200 |
} |
205 | 201 |
|
206 | 202 |
open(FH, "LANGUAGE"); |
... | ... | |
213 | 209 |
print "\n$trlanguage - ${per}%\n"; |
214 | 210 |
|
215 | 211 |
exit; |
216 |
# eom |
|
217 | 212 |
|
213 |
# eom |
|
218 | 214 |
|
219 | 215 |
sub scanfile { |
220 | 216 |
my $file = shift; |
221 | 217 |
|
222 | 218 |
return unless (-f "$file"); |
223 |
|
|
219 |
|
|
224 | 220 |
my $fh = new FileHandle; |
225 | 221 |
open $fh, "$file" or die "$! : $file"; |
226 | 222 |
|
227 | 223 |
my ($is_submit, $line_no, $sub_line_no) = (0, 0, 0); |
228 |
|
|
224 |
|
|
229 | 225 |
while (<$fh>) { |
230 | 226 |
$line_no++; |
227 |
|
|
231 | 228 |
# is this another file |
232 | 229 |
if (/require\s+\W.*\.pl/) { |
233 | 230 |
my $newfile = $&; |
... | ... | |
235 | 232 |
$newfile =~ s/\$form->{path}\///; |
236 | 233 |
&scanfile("$bindir/$newfile"); |
237 | 234 |
} |
238 |
|
|
235 |
|
|
239 | 236 |
# is this a sub ? |
240 | 237 |
if (/^sub /) { |
241 | 238 |
($null, $subrt) = split / +/; |
242 | 239 |
$subrt{$subrt} = 1; |
243 | 240 |
next; |
244 | 241 |
} |
245 |
|
|
242 |
|
|
246 | 243 |
my $rc = 1; |
247 |
|
|
244 |
|
|
248 | 245 |
while ($rc) { |
249 | 246 |
if (/Locale/) { |
250 |
unless (/^use /) {
|
|
251 |
my ($null, $country) = split /,/;
|
|
252 |
$country =~ s/^ +[\"\']//;
|
|
253 |
$country =~ s/[\"\'].*//;
|
|
254 |
}
|
|
247 |
unless (/^use /) {
|
|
248 |
my ($null, $country) = split /,/;
|
|
249 |
$country =~ s/^ +[\"\']//;
|
|
250 |
$country =~ s/[\"\'].*//;
|
|
251 |
}
|
|
255 | 252 |
} |
256 | 253 |
|
257 | 254 |
my $postmatch = ""; |
255 |
|
|
258 | 256 |
# is it a submit button before $locale-> |
259 | 257 |
if (/type\s*=\s*submit/i) { |
260 | 258 |
$postmatch = $'; |
261 | 259 |
if ($` !~ /\$locale->text/) { |
262 |
$is_submit = 1; |
|
260 |
$is_submit = 1;
|
|
263 | 261 |
$sub_line_no = $line_no; |
264 | 262 |
} |
265 | 263 |
} |
... | ... | |
268 | 266 |
my $postmatch = $'; |
269 | 267 |
|
270 | 268 |
if ($found) { |
271 |
my $string = $&;
|
|
272 |
$string =~ s/\$locale->text\(\s*[\'\"(q|qq)][\'\/\\\|~]*//;
|
|
273 |
$string =~ s/\W\)+.*$//;
|
|
269 |
my $string = $&;
|
|
270 |
$string =~ s/\$locale->text\(\s*[\'\"(q|qq)][\'\/\\\|~]*//;
|
|
271 |
$string =~ s/\W\)+.*$//;
|
|
274 | 272 |
|
275 | 273 |
# if there is no $ in the string record it |
276 |
unless ($string =~ /\$\D.*/) { |
|
277 |
# this guarantees one instance of string |
|
278 |
$locale{$string} = 1; |
|
274 |
unless ($string =~ /\$\D.*/) { |
|
275 |
|
|
276 |
# this guarantees one instance of string |
|
277 |
$locale{$string} = 1; |
|
279 | 278 |
|
280 | 279 |
# this one is for all the locales |
281 |
$alllocales{$string} = 1;
|
|
280 |
$alllocales{$string} = 1;
|
|
282 | 281 |
|
283 | 282 |
# is it a submit button before $locale-> |
284 | 283 |
if ($is_submit) { |
285 |
$submit{$string} = 1;
|
|
284 |
$submit{$string} = 1;
|
|
286 | 285 |
} |
287 |
}
|
|
286 |
}
|
|
288 | 287 |
} elsif ($postmatch =~ />/) { |
289 | 288 |
$is_submit = 0; |
290 | 289 |
} |
291 | 290 |
|
292 | 291 |
# exit loop if there are no more locales on this line |
293 | 292 |
($rc) = ($postmatch =~ /\$locale->text/); |
293 |
|
|
294 | 294 |
# strip text |
295 | 295 |
s/^.*?\$locale->text.*?\)//; |
296 | 296 |
|
297 |
if (($postmatch =~ />/) ||
|
|
298 |
(!$found && ($sub_line_no != $line_no) && />/)) { |
|
297 |
if ( ($postmatch =~ />/)
|
|
298 |
|| (!$found && ($sub_line_no != $line_no) && />/)) {
|
|
299 | 299 |
$is_submit = 0; |
300 | 300 |
} |
301 | 301 |
} |
... | ... | |
305 | 305 |
|
306 | 306 |
} |
307 | 307 |
|
308 |
|
|
309 | 308 |
sub scanmenu { |
310 | 309 |
my $file = shift; |
311 | 310 |
|
... | ... | |
317 | 316 |
|
318 | 317 |
# strip [] |
319 | 318 |
grep { s/(\[|\])//g } @a; |
320 |
|
|
319 |
|
|
321 | 320 |
foreach my $item (@a) { |
322 | 321 |
@b = split /--/, $item; |
323 | 322 |
foreach $string (@b) { |
324 | 323 |
chomp $string; |
325 |
$locale{$string} = 1; |
|
324 |
$locale{$string} = 1;
|
|
326 | 325 |
$alllocales{$string} = 1; |
327 | 326 |
} |
328 | 327 |
} |
329 |
|
|
330 |
} |
|
331 | 328 |
|
329 |
} |
|
332 | 330 |
|
Auch abrufbar als: Unified diff
Einmal durch perltidy.