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";
39 $FEXHOME = $ENV{FEXHOME} || $FEX[7];
41 # require "$FEXHOME/lib/fex.pp"
42 # or die "$0: cannot load $FEXHOME/lib/fex.pp - $!\n";
44 $tr = "locale/translations";
46 $lang = shift or &usage;
47 exit if $lang eq 'english';
49 open $tr,$tr or die "$0: cannot open $tr - $!\n";
54 if (/^#\s*([\w-]+):/ and $lang eq $1) {
66 die "$0: syntax error in $tr line $. : no text\n";
69 for my $l (2 .. $ll) {
73 die "$0: syntax error in $tr line $. : no text\n";
77 while (<$tr>) { last if /^\s*$/ }
81 @E = sort {length $b <=> length $a} keys %T;
83 mkdir "$FEXHOME/locale";
84 $_ = "$FEXHOME/locale/english";
85 symlink '..',$_ unless -e;
87 foreach $file (@trfiles) {
89 mkdirp("$FEXHOME/locale/$lang/".dirname($file));
90 $fe = "$FEXHOME/$file";
91 $ft = "$FEXHOME/locale/$lang/$file";
92 open $fe,"<$fe" or die "$0: cannot read $fe - $!\n";
93 unlink $ft; # beware symlink!
94 open $ft,">$ft" or die "$0: cannot write $ft - $!\n";
102 chmod((stat $fe)[2],$ft);
103 print "$ft written\n";
106 if ($FEXHOME !~ /fexdev/) {
108 foreach $file (@cpfiles) {
109 my $fs = "locale/$lang/$file";
111 my $fd = "$FEXHOME/$fs";
112 mkdirp(dirname($fd));
114 $fd .= '_new' if -e $fd;
116 chmod((stat $fs)[2],$fd);
117 print "$fd written\n";
121 my $fds = $fd.'_save';
122 my $fdn = $fd.'_new';
123 system "rm -rf $fds $fdn";
125 system "tar cf - $fs | (cd $FEXHOME; tar xf -)";
128 print "$fdn written\n";
130 system "tar cf - $fs | (cd $FEXHOME; tar xf -)";
131 print "$fd written\n";
137 foreach $fs (qw(fex.ph dop)) {
138 $fd = "$FEXHOME/locale/$lang/lib/$fs";
139 symlink "../../../lib/$fs",$fd and print "$fd linked\n";
142 unless (-f "$FEXHOME/locale/$lang/htdocs/FAQ/meta.faq") {
143 unlink "$FEXHOME/locale/$lang/htdocs/FAQ/FAQ.html";
144 rmdir "$FEXHOME/locale/$lang/htdocs/FAQ";
150 make_lf('english'); # unless -f "$FEXHOME/lib/lf.pl";
157 my $fexpp = "$FEXHOME/locale/$lang/lib/fex.pp";
158 my $lf = "$FEXHOME/locale/$lang/lib/lf.pl";
160 open $fexpp,$fexpp or die "$0: no $fexpp - $!\n";
162 open $lf,'>',$lf or die "$0: cannot write $lf - $!\n";
163 print {$lf} "### auto-generated by install/translate - DO NOT EDIT! ###\n\n";
166 s/.*\n(\#\#\#* locale functions)/$1/s;
167 s/\nsub (\w+)/\n\$$1\{$lang\} = sub/gs;
183 die "$0: cannot mkdir /\n" unless $dir;
185 if ($pdir =~ s:/[^/]+$::) {
186 mkdirp($pdir) unless -d $pdir;
189 mkdir $dir,0770 or die "$0: mkdir $dir - $!\n";
197 open $tr,$tr or die "$0: cannot open $tr - $!\n";
201 push @langs,$1 if /^#\s*([\w-]+):/;
204 foreach my $lang (@langs) {
205 if (not -l "locale/$lang" and -f "locale/$lang/lib/fup.pl") {
206 print "usage: $0 $lang\n";