3 # translate english F*EX files into locale languange
22 # htdocs/FAQ/admin.faq
33 @FEX = getpwnam('fex') or die "$0: no user fex\n";
37 $FEXHOME = $ENV{FEXHOME} || $FEX[7];
39 # require "$FEXHOME/lib/fex.pp"
40 # or die "$0: cannot load $FEXHOME/lib/fex.pp - $!\n";
42 $tr = "locale/translations";
44 $lang = shift or &usage;
45 exit if $lang eq 'english';
47 open $tr,$tr or die "$0: cannot open $tr - $!\n";
52 if (/^#\s*([\w-]+):/ and $lang eq $1) {
64 die "$0: syntax error in $tr line $. : no text\n";
67 for my $l (2 .. $ll) {
71 die "$0: syntax error in $tr line $. : no text\n";
75 while (<$tr>) { last if /^\s*$/ }
79 @E = sort {length $b <=> length $a} keys %T;
81 mkdir "$FEXHOME/locale";
82 $_ = "$FEXHOME/locale/english";
83 symlink '..',$_ unless -e;
85 foreach $file (@trfiles) {
87 mkdirp("$FEXHOME/locale/$lang/".dirname($file));
88 $fe = "$FEXHOME/$file";
89 $ft = "$FEXHOME/locale/$lang/$file";
90 open $fe,"<$fe" or die "$0: cannot read $fe - $!\n";
91 unlink $ft; # beware symlink!
92 open $ft,">$ft" or die "$0: cannot write $ft - $!\n";
100 chmod((stat $fe)[2],$ft);
101 print "$ft written\n";
104 foreach $file (@cpfiles) {
105 my $fs = "locale/$lang/$file";
107 my $fd = "$FEXHOME/$fs";
108 mkdirp(dirname($fd));
110 $fd .= '_new' if -e $fd;
112 chmod((stat $fs)[2],$fd);
113 print "$fd written\n";
117 my $fds = $fd.'_save';
118 my $fdn = $fd.'_new';
119 system "rm -rf $fds $fdn";
121 system "tar cf - $fs | (cd $FEXHOME; tar xf -)";
124 print "$fdn written\n";
126 system "tar cf - $fs | (cd $FEXHOME; tar xf -)";
127 print "$fd written\n";
133 foreach $fs (qw(fex.ph dop)) {
134 $fd = "$FEXHOME/locale/$lang/lib/$fs";
135 symlink "../../../lib/$fs",$fd and print "$fd linked\n";
138 unless (-f "$FEXHOME/locale/$lang/htdocs/FAQ/meta.faq") {
139 unlink "$FEXHOME/locale/$lang/htdocs/FAQ/FAQ.html";
140 rmdir "$FEXHOME/locale/$lang/htdocs/FAQ";
144 make_lf('english'); # unless -f "$FEXHOME/lib/lf.pl";
151 my $fexpp = "$FEXHOME/locale/$lang/lib/fex.pp";
152 my $lf = "$FEXHOME/locale/$lang/lib/lf.pl";
154 open $fexpp,$fexpp or die "$0: no $fexpp - $!\n";
156 open $lf,'>',$lf or die "$0: cannot write $lf - $!\n";
157 print {$lf} "### auto-generated by install/translate - DO NOT EDIT! ###\n\n";
160 s/.*\n(\#\#\#* locale functions)/$1/s;
161 s/\nsub (\w+)/\n\$$1\{$lang\} = sub/gs;
177 die "$0: cannot mkdir /\n" unless $dir;
179 if ($pdir =~ s:/[^/]+$::) {
180 mkdirp($pdir) unless -d $pdir;
183 mkdir $dir,0770 or die "$0: mkdir $dir - $!\n";
191 open $tr,$tr or die "$0: cannot open $tr - $!\n";
195 push @langs,$1 if /^#\s*([\w-]+):/;
198 foreach my $lang (@langs) {
199 if (not -l "locale/$lang" and -f "locale/$lang/lib/fup.pl") {
200 print "usage: $0 $lang\n";