3 # -n do not include custom_ scripts
8 $bindir = "$basedir/bin/mozilla";
9 $menufile = "menu.ini";
11 foreach $item (@ARGV) {
16 opendir DIR, "$bindir" or die "$!";
17 @progfiles = grep { /\.pl/; !/(_|^\.)/ } readdir DIR;
19 @customfiles = grep /_/, readdir DIR;
22 # put customized files into @customfiles
23 @customfiles = () if ($arg{n});
26 @menufiles = ($menufile);
28 opendir DIR, "$basedir" or die "$!";
29 @menufiles = grep { /.*?_$menufile$/ } readdir DIR;
31 unshift @menufiles, $menufile;
34 # slurp the translations in
39 foreach $file (@progfiles) {
45 &scanfile("$bindir/$file");
47 # scan custom_{module}.pl or {login}_{module}.pl files
48 foreach $customfile (@customfiles) {
49 if ($customfile =~ /_$file/) {
50 if (-f "$bindir/$customfile") {
51 &scanfile("$bindir/$customfile");
56 # if this is the menu.pl file
57 if ($file eq 'menu.pl') {
58 foreach $item (@menufiles) {
59 &scanmenu("$basedir/$item");
63 if ($file eq 'menunew.pl') {
64 foreach $item (@menufiles) {
65 &scanmenu("$basedir/$item");
71 eval { require 'missing'; };
74 foreach $text (keys %$missing) {
76 unless ($self{texts}{$text}) {
77 $self{texts}{$text} = $missing->{$text};
82 open FH, ">$file" or die "$! : $file";
84 print FH q|$self{texts} = {
87 foreach $key (sort keys %locale) {
88 if ($self{texts}{$key}) {
89 $text = $self{texts}{$key};
97 $keytext =~ s/'/\\'/g;
98 $keytext =~ s/\\$/\\\\/;
100 print FH qq| '$keytext'|
101 . (' ' x (27 - length($keytext)))
102 . qq| => '$text',\n|;
110 foreach $key (sort keys %subrt) {
113 $text =~ s/\\$/\\\\/;
114 print FH qq| '$text'| . (' ' x (27 - length($text))) . qq| => '$text',\n|;
117 foreach $key (sort keys %submit) {
118 $text = ($self{texts}{$key}) ? $self{texts}{$key} : $key;
120 $text =~ s/\\$/\\\\/;
123 $english_sub =~ s/'/\\'/g;
124 $english_sub =~ s/\\$/\\\\/;
125 $english_sub = lc $key;
127 $translated_sub = lc $text;
128 $english_sub =~ s/( |-|,)/_/g;
129 $translated_sub =~ s/( |-|,)/_/g;
130 print FH qq| '$translated_sub'|
131 . (' ' x (27 - length($translated_sub)))
132 . qq| => '$english_sub',\n|;
145 open FH, ">all" or die "$! : all";
147 print FH q|# These are all the texts to build the translations files.
148 # The file has the form of 'english text' => 'foreign text',
149 # you can add the translation in this file or in the 'missing' file
150 # run locales.pl from this directory to rebuild the translation files
155 foreach $key (sort keys %alllocales) {
156 $text = $self{texts}{$key};
161 $text =~ s/\\$/\\\\/;
170 print FH qq| '$key'| . (' ' x (27 - length($key))) . qq| => '$text',\n|;
182 open FH, ">missing" or die "$! : missing";
184 print FH q|# add the missing texts and run locales.pl to rebuild
189 foreach $text (@missing) {
190 print FH qq| '$text'| . (' ' x (27 - length($text))) . qq| => '',\n|;
202 open(FH, "LANGUAGE");
205 $trlanguage = $language[0];
208 $per = sprintf("%.1f", ($count - $notext) / $count * 100);
209 print "\n$trlanguage - ${per}%\n";
218 return unless (-f "$file");
220 my $fh = new FileHandle;
221 open $fh, "$file" or die "$! : $file";
223 my ($is_submit, $line_no, $sub_line_no) = (0, 0, 0);
228 # is this another file
229 if (/require\s+\W.*\.pl/) {
231 $newfile =~ s/require\s+\W//;
232 $newfile =~ s/\$form->{path}\///;
233 &scanfile("$bindir/$newfile");
238 ($null, $subrt) = split / +/;
248 my ($null, $country) = split /,/;
249 $country =~ s/^ +[\"\']//;
250 $country =~ s/[\"\'].*//;
256 # is it a submit button before $locale->
257 if (/type\s*=\s*submit/i) {
259 if ($` !~ /\$locale->text/) {
261 $sub_line_no = $line_no;
265 my ($found) = /\$locale->text.*?\W\)/;
270 $string =~ s/\$locale->text\(\s*[\'\"(q|qq)][\'\/\\\|~]*//;
271 $string =~ s/\W\)+.*$//;
273 # if there is no $ in the string record it
274 unless ($string =~ /\$\D.*/) {
276 # this guarantees one instance of string
277 $locale{$string} = 1;
279 # this one is for all the locales
280 $alllocales{$string} = 1;
282 # is it a submit button before $locale->
284 $submit{$string} = 1;
287 } elsif ($postmatch =~ />/) {
291 # exit loop if there are no more locales on this line
292 ($rc) = ($postmatch =~ /\$locale->text/);
295 s/^.*?\$locale->text.*?\)//;
297 if ( ($postmatch =~ />/)
298 || (!$found && ($sub_line_no != $line_no) && />/)) {
311 my $fh = new FileHandle;
312 open $fh, "$file" or die "$! : $file";
314 my @a = grep /^\[/, <$fh>;
318 grep { s/(\[|\])//g } @a;
320 foreach my $item (@a) {
321 @b = split /--/, $item;
322 foreach $string (@b) {
324 $locale{$string} = 1;
325 $alllocales{$string} = 1;