From 195cbca4bc18d4cf280b3ae3053c04e02379a8af Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 28 Mar 2006 12:06:06 +0000 Subject: Now including a fairly good uplang replacement as well, as well as supporting NONE for phrases. Getting closer. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9307 a1c6a512-1295-4272-9138-f99709370657 --- tools/genlang2 | 131 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 84 insertions(+), 47 deletions(-) (limited to 'tools/genlang2') diff --git a/tools/genlang2 b/tools/genlang2 index 7d363d4cf7..e9c21fb65c 100755 --- a/tools/genlang2 +++ b/tools/genlang2 @@ -70,7 +70,7 @@ my $update = $u; my $english = $e; -my $check = $binary?1:0 + $prefix?1:0 + $update?1:0; +my $check = ($binary?1:0) + ($prefix?1:0) + ($update?1:0); if($check > 1) { print "Please use only one of -p, -u and -b\n"; @@ -209,8 +209,10 @@ if($english) { # a function that compares the english phrase with the translated one. # compare source strings and desc + +# Then output the updated version! sub compare { - my ($engref, $locref)=@_; + my ($idstr, $engref, $locref)=@_; my ($edesc, $ldesc); my ($esource, $lsource); my $mode=0; @@ -230,28 +232,52 @@ sub compare { } } + my @show; + my @source; + $mode = 0; for my $l (@$locref) { if($l =~ /^ *desc: (.*)/) { $ldesc=$1; + if($edesc ne $ldesc) { + $l = "### The 'desc' field differs from the english!\n### the previously used desc is commented below:\n### desc: $ldesc\n desc: $edesc\n"; + } + push @show, $l; } elsif($l =~ / *\/i) { $mode=1; + push @show, $l; } elsif($mode) { if($l =~ / *\<\/source\>/i) { - last; + $mode = 0; + print @show; + if($esource ne $lsource) { + print "### The section differs from the english!\n", + "### the previously used one is commented below:\n"; + for(split("\n", $lsource)) { + print "### $_\n"; + } + print $esource; + } + else { + print $lsource; + } + undef @show; # start over + + push @show, $l; + } + else { + $lsource .= "$l"; } - $lsource .= "$l"; + } + else { + push @show, $l; } } - if($edesc ne $ldesc) { - print "### The 'desc' field differs from the english!\n"; - } - if($esource ne $lsource) { - print "### The section differs from the english!\n"; - } + + print @show; } my $idcount; # counter for lang ID numbers @@ -295,34 +321,44 @@ while() { my $idstr = $phrase{'id'}; my $idnum; - # Use the ID name to figure out which id number range we should - # use for this phrase. Voice-only strings are separated. - if($idstr =~ /^VOICE/) { - $idnum = $voiceid++; + if($dest =~ /^none\z/i) { + # "none" as dest means that this entire phrase is to be + # ignored + print "dest is NONE!\n"; } else { - $idnum = $idcount++; - } - $id{$idstr} = $idnum; - $idnum[$idnum]=$idstr; + # Use the ID name to figure out which id number range we + # should use for this phrase. Voice-only strings are + # separated. - $source{$idstr}=$src; - $dest{$idstr}=$dest; - $voice{$idstr}=$voice; + if($idstr =~ /^VOICE/) { + $idnum = $voiceid++; + } + else { + $idnum = $idcount++; + } + + $id{$idstr} = $idnum; + $idnum[$idnum]=$idstr; + + $source{$idstr}=$src; + $dest{$idstr}=$dest; + $voice{$idstr}=$voice; + + if($verbose) { + print "id: $phrase{id} ($idnum)\n"; + print "source: $src\n"; + print "dest: $dest\n"; + print "voice: $voice\n"; + } - if($verbose) { - print "id: $phrase{id} ($idnum)\n"; - print "source: $src\n"; - print "dest: $dest\n"; - print "voice: $voice\n"; + undef $src; + undef $dest; + undef $voice; + undef %phrase; } - undef $src; - undef $dest; - undef $voice; - undef %phrase; - if($update) { my $e = $english{$idstr}; @@ -330,10 +366,12 @@ while() { # compare original english with this! my @eng = split("\n", $english{$idstr}); - compare(\@eng, \@phrase); + compare($idstr, \@eng, \@phrase); + + $english{$idstr}=""; # clear it } else { - print "### This phrase is not used, remove it!\n"; + print "### $idstr: The phrase is not used. Skipped\n"; } } undef @phrase; @@ -342,9 +380,6 @@ while() { # starts with a slash, this _ends_ this section $m = pop @m; # get back old value, the previous level's tag - if($update) { - print "$ll"; - } next; } # end of tag close @@ -352,9 +387,6 @@ while() { push @m, $m; # store old value $m = $1; - if($update) { - print "$ll"; - } next; } @@ -362,13 +394,22 @@ while() { my ($name, $val)=($1, $2); &$m($_, $name, $val); } - if($update) { - print "$ll"; - } - } close(LANG); +if($update) { + my $any=0; + for(keys %english) { + if($english{$_}) { + print "###\n", + "### This phrase below was not present in the translated file\n", + "\n"; + print $english{$_}; + print "\n"; + } + } +} + if($prefix) { # We create a .c and .h file @@ -499,7 +540,3 @@ if($verbose) { } } -#print "* phrase *\n"; -#for(keys %phrase) { -# print "$_\n"; -#} -- cgit v1.2.3