mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-14 07:32:35 -05:00
langv2
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9470 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a87203651e
commit
c06e7772ff
35 changed files with 176704 additions and 79645 deletions
135
tools/uplang
135
tools/uplang
|
|
@ -1,136 +1,7 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
if(!$ARGV[0]) {
|
||||
print <<MOO
|
||||
Usage: uplang <english file> <translated file>
|
||||
print <<MOO
|
||||
The tool formerly known as 'uplang' is no longer used. We now use
|
||||
genlang2 with the -u option to get updated language files.
|
||||
MOO
|
||||
;
|
||||
exit;
|
||||
}
|
||||
|
||||
my %ids, @ids;
|
||||
open(ENG, "<$ARGV[0]");
|
||||
while(<ENG>) {
|
||||
if($_ =~ /^ *\#/) {
|
||||
# comment
|
||||
next;
|
||||
}
|
||||
$_ =~ s/\r//g;
|
||||
if($_ =~ /^ *([a-z]+): *(.*)/) {
|
||||
($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'};
|
||||
$all{$set{'id'}, 'voice'}=$set{'voice'};
|
||||
|
||||
$ids{$set{'id'}}=1;
|
||||
push @ids, $set{'id'};
|
||||
undef %set;
|
||||
}
|
||||
}
|
||||
}
|
||||
close(ENG);
|
||||
|
||||
undef %set;
|
||||
my $cblock = 1;
|
||||
open(NEW, "<$ARGV[1]");
|
||||
while(<NEW>) {
|
||||
$_ =~ s/\r//g;
|
||||
|
||||
if($_ =~ /^ *\#/) {
|
||||
# comment
|
||||
if($_ !~ /^ *\#\#\#/) {
|
||||
# no special ### comment -> keep it
|
||||
if(!$cblock) {
|
||||
print "\n";
|
||||
$cblock = 1;
|
||||
}
|
||||
print $_;
|
||||
}
|
||||
next;
|
||||
}
|
||||
$cblock = 0;
|
||||
|
||||
if($_ =~ /^ *([a-z]+): *(.*)/) {
|
||||
($var, $value) = ($1, $2);
|
||||
|
||||
$set{$var} = $value;
|
||||
|
||||
if($var eq "new") {
|
||||
# the last one for a single phrase
|
||||
|
||||
if(!$ids{$set{'id'}}) {
|
||||
print "\n### ".$set{'id'}." was not found in the english file!\n";
|
||||
next;
|
||||
}
|
||||
|
||||
print "\nid: ".$set{'id'}."\n";
|
||||
|
||||
if($set{'desc'} ne $all{$set{'id'}, 'desc'}) {
|
||||
print "### Description changed! Previous description was:\n",
|
||||
"### \"".$set{'desc'}."\"\n";
|
||||
print "desc: ".$all{$set{'id'}, 'desc'}."\n";
|
||||
}
|
||||
else {
|
||||
print "desc: ".$set{'desc'}."\n";
|
||||
}
|
||||
|
||||
if($set{'eng'} ne $all{$set{'id'}, 'eng'}) {
|
||||
print "### English phrase was changed! Previous translation was made on:\n",
|
||||
"### ".$set{'eng'}."\n";
|
||||
print "eng: ".$all{$set{'id'}, 'eng'}."\n";
|
||||
}
|
||||
else {
|
||||
print "eng: ".$set{'eng'}."\n";
|
||||
}
|
||||
|
||||
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'};
|
||||
}
|
||||
}
|
||||
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'};
|
||||
}
|
||||
print "voice: ".$set{'voice'}."\n";
|
||||
|
||||
print "new: ".$set{'new'}."\n";
|
||||
|
||||
$ids{$set{'id'}}=0;
|
||||
undef %set;
|
||||
}
|
||||
}
|
||||
}
|
||||
close(NEW);
|
||||
|
||||
# output new phrases not already translated , in english.lang order
|
||||
for(@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 "voice: ".$all{$id, 'voice'}."\n";
|
||||
print "new: \n";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue