2 # Converts a module's zh_CN (simplified chinese) strings to zh_TW.Big5
5 use Encode::HanConvert;
9 -d "$m/lang" || die "$m is not a module directory";
11 &read_file("$m/lang/zh_CN", \%zh);
12 foreach $k (keys %zh) {
13 $zh{$k} = gb_to_big5($zh{$k});
15 &write_file_diff("$m/lang/zh_TW.Big5", \%zh);
17 # Translate the module.info file
19 &read_file("$m/module.info", \%minfo);
20 local %ominfo = %minfo;
21 if ($minfo{'desc_zh_CN'}) {
22 $minfo{'desc_zh_TW.Big5'} = gb_to_big5($minfo{'desc_zh_CN'});
23 &write_file_diff("$m/module.info", \%minfo);
26 # Translate the config.info file
28 if (&read_file("$m/config.info.zh_CN", \%cinfo)) {
29 local %ocinfo = %cinfo;
30 foreach $k (keys %cinfo) {
31 $cinfo{$k} = gb_to_big5($cinfo{$k});
33 &write_file_diff("$m/config.info.zh_TW.Big5", \%cinfo);
36 # Translate any help files
37 opendir(DIR, "$m/help");
38 foreach $h (readdir(DIR)) {
39 if ($h =~ /(\S+)\.zh_CN\.html$/) {
40 open(IN, "$m/help/$h");
41 open(OUT, ">$m/help/$1.zh_TW.Big5.html");
43 print OUT gb_to_big5($_);
52 # read_file(file, &assoc, [&order], [lowercase])
53 # Fill an associative array with name=value pairs from a file
56 open(ARFILE, $_[0]) || return 0;
59 if (!/^#/ && /^([^=]+)=(.*)$/) {
60 $_[1]->{$_[3] ? lc($1) : $1} = $2;
61 push(@{$_[2]}, $1) if ($_[2]);
68 # write_file_diff(file, array)
69 # Write out the contents of an associative array as name=value lines
73 &read_file($_[0], \%old, \@order);
74 return if (!&diff(\%old, $_[1]));
75 open(ARFILE, ">$_[0]");
77 print ARFILE $k,"=",$_[1]->{$k},"\n" if (exists($_[1]->{$k}));
79 foreach $k (keys %{$_[1]}) {
80 print ARFILE $k,"=",$_[1]->{$k},"\n" if (!exists($old{$k}));
83 print "Wrote $_[0]\n";
88 if (scalar(keys %{$_[0]}) != scalar(keys %{$_[1]})) {
91 foreach $k (keys %{$_[0]}) {
92 if ($_[0]->{$k} ne $_[1]->{$k}) {