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");
69 eval { require 'missing'; };
72 foreach $text (keys %$missing) {
74 unless ($self{texts}{$text}) {
75 $self{texts}{$text} = $missing->{$text};
81 open FH, ">$file" or die "$! : $file";
83 print FH q|$self{texts} = {
86 foreach $key (sort keys %locale) {
87 if ($self{texts}{$key}) {
88 $text = $self{texts}{$key};
96 $keytext =~ s/'/\\'/g;
97 $keytext =~ s/\\$/\\\\/;
99 print FH qq| '$keytext'|.(' ' x (27-length($keytext))).qq| => '$text',\n|;
107 foreach $key (sort keys %subrt) {
110 $text =~ s/\\$/\\\\/;
111 print FH qq| '$text'|.(' ' x (27-length($text))).qq| => '$text',\n|;
114 foreach $key (sort keys %submit) {
115 $text = ($self{texts}{$key}) ? $self{texts}{$key} : $key;
117 $text =~ s/\\$/\\\\/;
120 $english_sub =~ s/'/\\'/g;
121 $english_sub =~ s/\\$/\\\\/;
122 $english_sub = lc $key;
124 $translated_sub = lc $text;
125 $english_sub =~ s/( |-|,)/_/g;
126 $translated_sub =~ s/( |-|,)/_/g;
127 print FH qq| '$translated_sub'|.(' ' x (27-length($translated_sub))).qq| => '$english_sub',\n|;
141 open FH, ">all" or die "$! : all";
143 print FH q|# These are all the texts to build the translations files.
144 # The file has the form of 'english text' => 'foreign text',
145 # you can add the translation in this file or in the 'missing' file
146 # run locales.pl from this directory to rebuild the translation files
152 foreach $key (sort keys %alllocales) {
153 $text = $self{texts}{$key};
158 $text =~ s/\\$/\\\\/;
167 print FH qq| '$key'|.(' ' x (27-length($key))).qq| => '$text',\n|;
180 open FH, ">missing" or die "$! : missing";
182 print FH q|# add the missing texts and run locales.pl to rebuild
187 foreach $text (@missing) {
188 print FH qq| '$text'|.(' ' x (27-length($text))).qq| => '',\n|;
200 open(FH, "LANGUAGE");
203 $trlanguage = $language[0];
206 $per = sprintf("%.1f", ($count - $notext) / $count * 100);
207 print "\n$trlanguage - ${per}%\n";
216 return unless (-f "$file");
218 my $fh = new FileHandle;
219 open $fh, "$file" or die "$! : $file";
222 # is this another file
223 if (/require\s+\W.*\.pl/) {
225 $newfile =~ s/require\s+\W//;
226 $newfile =~ s/\$form->{path}\///;
227 &scanfile("$bindir/$newfile");
232 ($null, $subrt) = split / +/;
242 my ($null, $country) = split /,/;
243 $country =~ s/^ +["']//;
244 $country =~ s/["'].*//;
248 if (/\$locale->text.*?\W\)/) {
250 $string =~ s/\$locale->text\(\s*['"(q|qq)]['\/\\\|~]*//;
251 $string =~ s/\W\)+.*$//;
253 # if there is no $ in the string record it
254 unless ($string =~ /\$\D.*/) {
255 # this guarantees one instance of string
256 $locale{$string} = 1;
258 # this one is for all the locales
259 $alllocales{$string} = 1;
261 # is it a submit button before $locale->
263 $submit{$string} = 1;
268 # exit loop if there are no more locales on this line
269 ($rc) = ($' =~ /\$locale->text/);
271 s/^.*?\$locale->text.*?\)//;
283 my $fh = new FileHandle;
284 open $fh, "$file" or die "$! : $file";
286 my @a = grep /^\[/, <$fh>;
290 grep { s/(\[|\])//g } @a;
292 foreach my $item (@a) {
293 @b = split /--/, $item;
294 foreach $string (@b) {
296 $locale{$string} = 1;
297 $alllocales{$string} = 1;