13
sub loaddtd { # ($file)
16
#print "+ Loading $file\n";
25
open($fic, $file) || die "Could not open $file";
33
if (length(trim($buf)) == 0) {
36
elsif ($buf =~ /^<!ENTITY (.*)"(.*)">\s*$'/i) {
38
# print "+ Line '$ind'\n";
40
if ($ind eq "enigmail.ruleEmail.tooltip"
41
|| $ind eq "enigmail.noHushMailSupport.label"
42
|| $ind eq "enigmail.noHushMailSupport.tooltip") {
46
$tab->{$ind} = "$1\"$val\">";
49
elsif ($buf =~ /^<!ENTITY (.*)"(.*)$/i) {
51
# print "+ Start '$ind'\n";
52
$tab->{$ind} = "$1\"$2";
55
elsif ($prev && $buf =~ /^(.*)">$/) {
56
# print "+ End '$prev'\n";
57
$tab->{$prev} .= "\n$1\">";
61
# print "+ Cont. '$prev'\n";
62
$tab->{$prev} .= "\n$buf";
65
die ("- in $file on line $line: unknown ($buf) !\n");
73
# Load properties file
74
sub loadprop { # ($file)
78
#print "+ Loading $file\n";
84
open($fic, $file) || die "Could not open $file";
91
if (length(trim($buf)) == 0) {
94
elsif ($buf =~ /^\s*#/) {
95
#print "+ comments\n";
97
elsif ($buf =~ /^\s*([A-Za-z0-9._]+)\s*=\s*(.*)/) {
98
#print "+ Value '$1'\n";
100
$tab->{$ind} = "$1=$2";
103
print ("\tIgnored ($buf) !\n");
111
($#ARGV > 0) || die ("usage fixlang.pl fromdir destdir\n fromdir: original en-US locale directory\n destdir: locale lanugage dir\n");
115
(-f "$from/enigmail.dtd") || die ("$from/enigmail.dtd not found\n");
116
(-f "$dest/enigmail.dtd") || die ("$dest/enigmail.dtd not found\n");
117
(-f "$from/enigmail.properties") || die ("$from/enigmail.properties not found\n");
118
(-f "$dest/enigmail.properties") || die ("$dest/enigmail.properties not found\n");
120
my $endtd = loaddtd("$from/enigmail.dtd");
121
my $frdtd = loaddtd("$dest/enigmail.dtd");
123
print "+ Writing $dest/enigmail.dtd\n";
124
open(OUT, ">$dest/enigmail.dtd") || die "Cannot write to $dest/enigmail.dtd";
126
for my $ind (keys %$endtd) {
128
if ($frdtd->{$ind}) {
129
print OUT "<!ENTITY $frdtd->{$ind}\n";
132
print "\tAdding missing $ind\n";
133
print OUT "<!ENTITY $endtd->{$ind}\n";
139
my $enprop = loadprop("$from/enigmail.properties");
140
my $frprop = loadprop("$dest/enigmail.properties");
142
print "+ Writing $dest/enigmail.properties\n";
143
open(OUT, ">$dest/enigmail.properties") || die "Cannot write to $dest/enigmail.properties";
144
for my $ind (keys %$enprop) {
145
if ($frprop->{$ind}) {
146
print OUT "$frprop->{$ind}\n";
148
print "\tAdding missing $ind\n";
149
print OUT "$enprop->{$ind}\n";