2002-09-16 15:02:11 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
if(!$ARGV[0]) {
|
|
|
|
print <<MOO
|
|
|
|
Usage: lang.pl <english file> <translated file>
|
|
|
|
MOO
|
|
|
|
;
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2002-09-20 06:36:49 +00:00
|
|
|
my %ids;
|
2002-09-16 15:02:11 +00:00
|
|
|
open(ENG, "<$ARGV[0]");
|
|
|
|
while(<ENG>) {
|
2003-04-29 12:38:32 +00:00
|
|
|
if($_ =~ /^ *\#/) {
|
2002-09-16 15:02:11 +00:00
|
|
|
# comment
|
|
|
|
next;
|
|
|
|
}
|
2002-09-20 06:36:49 +00:00
|
|
|
$_ =~ s/\r//g;
|
2003-04-29 12:38:32 +00:00
|
|
|
if($_ =~ /^ *([a-z]+): *(.*)/) {
|
2002-09-16 15:02:11 +00:00
|
|
|
($var, $value) = ($1, $2);
|
|
|
|
# print "$var => $value\n";
|
|
|
|
|
|
|
|
$set{$var} = $value;
|
|
|
|
|
|
|
|
if($var eq "new") {
|
|
|
|
# the last one for a single phrase
|
|
|
|
$all{$set{'id'}, 'desc'}=$set{'desc'};
|
|
|
|
$all{$set{'id'}, 'eng'}=$set{'eng'};
|
|
|
|
|
|
|
|
$ids{$set{'id'}}=1;
|
|
|
|
undef %set;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(ENG);
|
|
|
|
|
|
|
|
undef %set;
|
|
|
|
open(NEW, "<$ARGV[1]");
|
|
|
|
while(<NEW>) {
|
2003-04-29 12:38:32 +00:00
|
|
|
if($_ =~ /^ *\#/) {
|
2002-09-16 15:02:11 +00:00
|
|
|
# comment
|
|
|
|
next;
|
|
|
|
}
|
2002-09-20 06:36:49 +00:00
|
|
|
$_ =~ s/\r//g;
|
|
|
|
|
2003-04-29 12:38:32 +00:00
|
|
|
if($_ =~ /^ *([a-z]+): *(.*)/) {
|
2002-09-16 15:02:11 +00:00
|
|
|
($var, $value) = ($1, $2);
|
|
|
|
|
|
|
|
$set{$var} = $value;
|
|
|
|
|
|
|
|
if($var eq "new") {
|
|
|
|
# the last one for a single phrase
|
|
|
|
|
2002-09-20 06:36:49 +00:00
|
|
|
if(!$ids{$set{'id'}}) {
|
|
|
|
print "### ".$set{'id'}." was not found in the english file!\n";
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2002-09-16 15:02:11 +00:00
|
|
|
print "\nid: ".$set{'id'}."\n";
|
2002-10-15 11:58:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
if($set{'desc'} ne $all{$set{'id'}, 'desc'}) {
|
|
|
|
print "### Description changed! Previous description was:\n",
|
|
|
|
"### \"".$set{'desc'}."\"\n";
|
|
|
|
$set{'desc'} = $all{$set{'id'}, 'desc'};
|
|
|
|
}
|
|
|
|
|
2002-09-16 15:02:11 +00:00
|
|
|
print "desc: ".$set{'desc'}."\n";
|
|
|
|
if($set{'eng'} ne $all{$set{'id'}, 'eng'}) {
|
|
|
|
print "### English phrase was changed! Previous translation was made on:\n",
|
2002-10-15 11:58:13 +00:00
|
|
|
"### ".$set{'eng'}."\n";
|
2002-09-16 15:02:11 +00:00
|
|
|
$set{'eng'} = $all{$set{'id'}, 'eng'};
|
|
|
|
}
|
|
|
|
print "eng: ".$set{'eng'}."\n";
|
|
|
|
print "new: ".$set{'new'}."\n";
|
|
|
|
|
|
|
|
$ids{$set{'id'}}=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(NEW);
|
|
|
|
|
|
|
|
# output new phrases not already translated
|
|
|
|
for(sort keys %ids) {
|
|
|
|
if($ids{$_}) {
|
|
|
|
my $id=$_;
|
|
|
|
print "\nid: $_\n";
|
|
|
|
print "desc: ".$all{$id, 'desc'}."\n";
|
|
|
|
print "eng: ".$all{$id, 'eng'}."\n";
|
|
|
|
print "### Not previously translated\n";
|
|
|
|
print "new: \n";
|
|
|
|
}
|
|
|
|
}
|