2002-09-16 15:02:11 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
if(!$ARGV[0]) {
|
|
|
|
print <<MOO
|
2006-02-13 08:51:33 +00:00
|
|
|
Usage: uplang <english file> <translated file>
|
2002-09-16 15:02:11 +00:00
|
|
|
MOO
|
|
|
|
;
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2005-02-01 01:35:17 +00:00
|
|
|
my %ids, @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'};
|
2004-03-30 15:07:17 +00:00
|
|
|
$all{$set{'id'}, 'voice'}=$set{'voice'};
|
2002-09-16 15:02:11 +00:00
|
|
|
|
|
|
|
$ids{$set{'id'}}=1;
|
2005-02-01 01:35:17 +00:00
|
|
|
push @ids, $set{'id'};
|
2002-09-16 15:02:11 +00:00
|
|
|
undef %set;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(ENG);
|
|
|
|
|
|
|
|
undef %set;
|
2005-02-01 19:00:37 +00:00
|
|
|
my $cblock = 1;
|
2002-09-16 15:02:11 +00:00
|
|
|
open(NEW, "<$ARGV[1]");
|
|
|
|
while(<NEW>) {
|
2005-02-01 19:00:37 +00:00
|
|
|
$_ =~ s/\r//g;
|
|
|
|
|
2003-04-29 12:38:32 +00:00
|
|
|
if($_ =~ /^ *\#/) {
|
2002-09-16 15:02:11 +00:00
|
|
|
# comment
|
2005-02-01 19:00:37 +00:00
|
|
|
if($_ !~ /^ *\#\#\#/) {
|
|
|
|
# no special ### comment -> keep it
|
|
|
|
if(!$cblock) {
|
|
|
|
print "\n";
|
|
|
|
$cblock = 1;
|
|
|
|
}
|
|
|
|
print $_;
|
|
|
|
}
|
2002-09-16 15:02:11 +00:00
|
|
|
next;
|
|
|
|
}
|
2005-02-01 19:00:37 +00:00
|
|
|
$cblock = 0;
|
2002-09-20 06:36:49 +00:00
|
|
|
|
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'}}) {
|
2005-02-01 19:00:37 +00:00
|
|
|
print "\n### ".$set{'id'}." was not found in the english file!\n";
|
2002-09-20 06:36:49 +00:00
|
|
|
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";
|
2005-02-01 01:35:17 +00:00
|
|
|
print "desc: ".$all{$set{'id'}, 'desc'}."\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "desc: ".$set{'desc'}."\n";
|
2002-10-15 11:58:13 +00:00
|
|
|
}
|
2004-03-30 15:07:17 +00:00
|
|
|
|
2002-09-16 15:02:11 +00:00
|
|
|
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";
|
2005-02-01 01:35:17 +00:00
|
|
|
print "eng: ".$all{$set{'id'}, 'eng'}."\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "eng: ".$set{'eng'}."\n";
|
2002-09-16 15:02:11 +00:00
|
|
|
}
|
2004-03-30 15:07:17 +00:00
|
|
|
|
2005-02-01 01:35:17 +00:00
|
|
|
if($set{'id'} =~ /^VOICE_/) { # voice only, compare desc:
|
|
|
|
if($set{'desc'} ne $all{$set{'id'}, 'desc'}) {
|
|
|
|
print "### Voice only: description changed! Voice set to english. Previous voice was:\n",
|
|
|
|
"### ".$set{'voice'}."\n";
|
|
|
|
$set{'voice'} = $all{$set{'id'}, 'voice'};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { # standard entry, compare eng:
|
|
|
|
if($set{'eng'} ne $all{$set{'id'}, 'eng'}
|
|
|
|
#only if either original or translated voice: is non-empty
|
|
|
|
and ($set{'voice'} !~ /^(\"\")? *$/
|
|
|
|
or $all{$set{'id'}, 'voice'} !~ /^(\"\")? *$/)) {
|
|
|
|
print "### English phrase was changed! Voice set to english. Previous voice was:\n",
|
|
|
|
"### ".$set{'voice'}."\n";
|
|
|
|
$set{'voice'} = $all{$set{'id'}, 'voice'};
|
|
|
|
}
|
2004-03-30 15:07:17 +00:00
|
|
|
}
|
2005-02-07 22:33:32 +00:00
|
|
|
if($set{'voice'} =~ /^(\"\")? *$/
|
|
|
|
and $all{$set{'id'}, 'voice'} !~ /^(\"\")? *$/) {
|
|
|
|
print "### Voice not found in previous translation. Set to english.\n";
|
|
|
|
$set{'voice'} = $all{$set{'id'}, 'voice'};
|
|
|
|
}
|
2004-03-30 15:07:17 +00:00
|
|
|
print "voice: ".$set{'voice'}."\n";
|
|
|
|
|
2002-09-16 15:02:11 +00:00
|
|
|
print "new: ".$set{'new'}."\n";
|
|
|
|
|
|
|
|
$ids{$set{'id'}}=0;
|
2005-02-07 22:33:32 +00:00
|
|
|
undef %set;
|
2002-09-16 15:02:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(NEW);
|
|
|
|
|
2005-02-01 01:35:17 +00:00
|
|
|
# output new phrases not already translated , in english.lang order
|
|
|
|
for(@ids) {
|
2002-09-16 15:02:11 +00:00
|
|
|
if($ids{$_}) {
|
|
|
|
my $id=$_;
|
|
|
|
print "\nid: $_\n";
|
|
|
|
print "desc: ".$all{$id, 'desc'}."\n";
|
|
|
|
print "eng: ".$all{$id, 'eng'}."\n";
|
|
|
|
print "### Not previously translated\n";
|
2005-02-01 01:35:17 +00:00
|
|
|
print "voice: ".$all{$id, 'voice'}."\n";
|
2002-09-16 15:02:11 +00:00
|
|
|
print "new: \n";
|
|
|
|
}
|
|
|
|
}
|