3 # -n do not include custom_ scripts
10 $bindir = "$basedir/bin/mozilla";
11 $menufile = "menu.ini";
13 foreach $item (@ARGV) {
18 opendir DIR, "$bindir" or die "$!";
19 @progfiles = grep { /\.pl/; !/(_|^\.)/ } readdir DIR;
21 @customfiles = grep /_/, readdir DIR;
24 # put customized files into @customfiles
25 @customfiles = () if ($arg{n});
28 @menufiles = ($menufile);
30 opendir DIR, "$basedir" or die "$!";
31 @menufiles = grep { /.*?_$menufile$/ } readdir DIR;
33 unshift @menufiles, $menufile;
37 if (-f 'all') { # use the old all file
39 %oldall = %{ $self{texts} };
42 # remove the old missing file
47 foreach $file (@progfiles) {
57 # read $file if it exists
58 eval { require "$file"; };
60 &scanfile("$bindir/${file}.pl");
62 # scan custom_{module}.pl or {login}_{module}.pl files
63 foreach $customfile (@customfiles) {
64 if ($customfile =~ /_${file}\.pl/) {
65 if (-f "$bindir/$customfile") {
66 &scanfile("$bindir/$customfile");
71 # if this is the menu.pl file
72 if ($file eq 'menu') {
73 foreach $item (@menufiles) {
74 &scanmenu("$basedir/$item");
78 eval { require "$file.missing"; };
79 unlink "$file.missing";
81 if (%oldall) { # use the old all file
82 %{ $self{texts} } = %oldall;
85 map { $self{texts}{$_} = $missing->{$_} if $missing->{$_} } keys %$missing;
87 open FH, ">$file" or die "$! : $file";
89 print FH q|$self{texts} = {
92 foreach $key (sort keys %locale) {
93 $text = $self{texts}{$key};
100 $keytext =~ s/'/\\'/g;
101 $keytext =~ s/\\$/\\\\/;
103 $all{$keytext} = $text;
107 push @missing, $keytext;
111 print FH qq| '$keytext'|.(' ' x (27-length($keytext))).qq| => '$text',\n|;
119 foreach $key (sort keys %subrt) {
122 $text =~ s/\\$/\\\\/;
123 print FH qq| '$text'|.(' ' x (27-length($text))).qq| => '$text',\n|;
126 foreach $key (sort keys %submit) {
127 $text = ($self{texts}{$key}) ? $self{texts}{$key} : $key;
129 $text =~ s/\\$/\\\\/;
132 $english_sub =~ s/'/\\'/g;
133 $english_sub =~ s/\\$/\\\\/;
134 $english_sub = lc $key;
136 $translated_sub = lc $text;
137 $english_sub =~ s/( |-|,)/_/g;
138 $translated_sub =~ s/( |-|,)/_/g;
139 print FH qq| '$translated_sub'|.(' ' x (27-length($translated_sub))).qq| => '$english_sub',\n|;
151 open FH, ">$file.missing" or die "$! : missing";
153 print FH qq|# module $file
154 # add the missing texts and run locales.pl to rebuild
159 foreach $text (@missing) {
160 print FH qq| '$text'|.(' ' x (27-length($text))).qq| => '',\n|;
173 # redo the old all file
175 open FH, ">all" or die "$! : all";
177 print FH qq|# These are all the texts to build the translations files.
178 # to build unique strings edit the module files instead
179 # this file is just a shortcut to build strings which are the same
184 foreach $text (sort keys %all) {
185 print FH qq| '$text'|.(' ' x (27-length($text))).qq| => '$all{$text}',\n|;
199 open(FH, "LANGUAGE");
202 $trlanguage = $language[0];
205 $per = sprintf("%.1f", ($count - $notext) / $count * 100);
206 print "\n$trlanguage - ${per}%\n";
215 return unless (-f "$file");
217 my $fh = new FileHandle;
218 open $fh, "$file" or die "$! : $file";
221 # is this another file
222 if (/require\s+\W.*\.pl/) {
224 $newfile =~ s/require\s+\W//;
225 $newfile =~ s/\$form->{path}\///;
226 &scanfile("$bindir/$newfile");
231 ($null, $subrt) = split / +/;
241 my ($null, $country) = split /,/;
242 $country =~ s/^ +["']//;
243 $country =~ s/["'].*//;
247 if (/\$locale->text.*?\W\)/) {
249 $string =~ s/\$locale->text\(\s*['"(q|qq)]['\/\\\|~]*//;
250 $string =~ s/\W\)+.*$//;
252 # if there is no $ in the string record it
253 unless ($string =~ /\$\D.*/) {
254 # this guarantees one instance of string
255 $locale{$string} = 1;
257 # is it a submit button before $locale->
258 if (/type=submit/i) {
259 $submit{$string} = 1;
264 # exit loop if there are no more locales on this line
265 ($rc) = ($' =~ /\$locale->text/);
267 s/^.*?\$locale->text.*?\)//;
279 my $fh = new FileHandle;
280 open $fh, "$file" or die "$! : $file";
282 my @a = grep /^\[/, <$fh>;
286 grep { s/(\[|\])//g } @a;
288 foreach my $item (@a) {
290 @b = split /--/, $item;
291 foreach $string (@b) {
293 $locale{$string} = 1 if $string !~ /^\s*$/;