3 # -n do not include custom_ scripts
9 $bindir = "$basedir/bin/mozilla";
10 $menufile = "menu.ini";
12 foreach $item (@ARGV) {
17 opendir DIR, "$bindir" or die "$!";
18 @progfiles = grep { /\.pl/; !/(_|^\.)/ } readdir DIR;
20 @customfiles = grep /_/, readdir DIR;
23 # put customized files into @customfiles
24 @customfiles = () if ($arg{n});
27 @menufiles = ($menufile);
29 opendir DIR, "$basedir" or die "$!";
30 @menufiles = grep { /.*?_$menufile$/ } readdir DIR;
32 unshift @menufiles, $menufile;
36 # slurp the translations in
42 foreach $file (@progfiles) {
48 &scanfile("$bindir/$file");
50 # scan custom_{module}.pl or {login}_{module}.pl files
51 foreach $customfile (@customfiles) {
52 if ($customfile =~ /_$file/) {
53 if (-f "$bindir/$customfile") {
54 &scanfile("$bindir/$customfile");
59 # if this is the menu.pl file
60 if ($file eq 'menu.pl') {
61 foreach $item (@menufiles) {
62 &scanmenu("$basedir/$item");
66 if ($file eq 'menunew.pl') {
67 foreach $item (@menufiles) {
68 &scanmenu("$basedir/$item");
75 eval { require 'missing'; };
78 foreach $text (keys %$missing) {
80 unless ($self{texts}{$text}) {
81 $self{texts}{$text} = $missing->{$text};
87 open FH, ">$file" or die "$! : $file";
89 print FH q|$self{texts} = {
92 foreach $key (sort keys %locale) {
93 if ($self{texts}{$key}) {
94 $text = $self{texts}{$key};
102 $keytext =~ s/'/\\'/g;
103 $keytext =~ s/\\$/\\\\/;
105 print FH qq| '$keytext'|.(' ' x (27-length($keytext))).qq| => '$text',\n|;
113 foreach $key (sort keys %subrt) {
116 $text =~ s/\\$/\\\\/;
117 print FH qq| '$text'|.(' ' x (27-length($text))).qq| => '$text',\n|;
120 foreach $key (sort keys %submit) {
121 $text = ($self{texts}{$key}) ? $self{texts}{$key} : $key;
123 $text =~ s/\\$/\\\\/;
126 $english_sub =~ s/'/\\'/g;
127 $english_sub =~ s/\\$/\\\\/;
128 $english_sub = lc $key;
130 $translated_sub = lc $text;
131 $english_sub =~ s/( |-|,)/_/g;
132 $translated_sub =~ s/( |-|,)/_/g;
133 print FH qq| '$translated_sub'|.(' ' x (27-length($translated_sub))).qq| => '$english_sub',\n|;
147 open FH, ">all" or die "$! : all";
149 print FH q|# These are all the texts to build the translations files.
150 # The file has the form of 'english text' => 'foreign text',
151 # you can add the translation in this file or in the 'missing' file
152 # run locales.pl from this directory to rebuild the translation files
158 foreach $key (sort keys %alllocales) {
159 $text = $self{texts}{$key};
164 $text =~ s/\\$/\\\\/;
173 print FH qq| '$key'|.(' ' x (27-length($key))).qq| => '$text',\n|;
186 open FH, ">missing" or die "$! : missing";
188 print FH q|# add the missing texts and run locales.pl to rebuild
193 foreach $text (@missing) {
194 print FH qq| '$text'|.(' ' x (27-length($text))).qq| => '',\n|;
206 open(FH, "LANGUAGE");
209 $trlanguage = $language[0];
212 $per = sprintf("%.1f", ($count - $notext) / $count * 100);
213 print "\n$trlanguage - ${per}%\n";
222 return unless (-f "$file");
224 my $fh = new FileHandle;
225 open $fh, "$file" or die "$! : $file";
227 my ($is_submit, $line_no, $sub_line_no) = (0, 0, 0);
231 # is this another file
232 if (/require\s+\W.*\.pl/) {
234 $newfile =~ s/require\s+\W//;
235 $newfile =~ s/\$form->{path}\///;
236 &scanfile("$bindir/$newfile");
241 ($null, $subrt) = split / +/;
251 my ($null, $country) = split /,/;
252 $country =~ s/^ +[\"\']//;
253 $country =~ s/[\"\'].*//;
258 # is it a submit button before $locale->
259 if (/type\s*=\s*submit/i) {
261 if ($` !~ /\$locale->text/) {
263 $sub_line_no = $line_no;
267 my ($found) = /\$locale->text.*?\W\)/;
272 $string =~ s/\$locale->text\(\s*[\'\"(q|qq)][\'\/\\\|~]*//;
273 $string =~ s/\W\)+.*$//;
275 # if there is no $ in the string record it
276 unless ($string =~ /\$\D.*/) {
277 # this guarantees one instance of string
278 $locale{$string} = 1;
280 # this one is for all the locales
281 $alllocales{$string} = 1;
283 # is it a submit button before $locale->
285 $submit{$string} = 1;
288 } elsif ($postmatch =~ />/) {
292 # exit loop if there are no more locales on this line
293 ($rc) = ($postmatch =~ /\$locale->text/);
295 s/^.*?\$locale->text.*?\)//;
297 if (($postmatch =~ />/) ||
298 (!$found && ($sub_line_no != $line_no) && />/)) {
312 my $fh = new FileHandle;
313 open $fh, "$file" or die "$! : $file";
315 my @a = grep /^\[/, <$fh>;
319 grep { s/(\[|\])//g } @a;
321 foreach my $item (@a) {
322 @b = split /--/, $item;
323 foreach $string (@b) {
325 $locale{$string} = 1;
326 $alllocales{$string} = 1;