From f22e6a59648debb9aaff7f9b05183a651b3787ce Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 20 May 2007 13:20:45 +0000 Subject: FS#6652 fix attempt. Make the phrase id counting take the dest pattern into account so that the binary and source code output gets the same numbering. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13443 a1c6a512-1295-4272-9138-f99709370657 --- tools/genlang | 56 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 14 deletions(-) (limited to 'tools') diff --git a/tools/genlang b/tools/genlang index 354f8217d2..e20ed637d1 100755 --- a/tools/genlang +++ b/tools/genlang @@ -182,6 +182,8 @@ if($english) { open(ENG, "<$english") || die "can't open $english"; my @phrase; my $id; + my $maybeid; + my $withindest; while() { # get rid of DOS newlines @@ -191,28 +193,54 @@ if($english) { # this is the start of a phrase } elsif($_ =~ /^ *\<\/phrase\>/) { - # this is the end of a phrase, add it to the english hash - $english{$id}=join("", @phrase); + + # if id is something, when we count and store this phrase + if($id) { + # voice-only entries get a difference range + if($id =~ /^VOICE_/) { + # Assign an ID number to this entry + $idmap{$id}=$vidnum; + $vidnum++; + } + else { + # Assign an ID number to this entry + $idmap{$id}=$idnum; + $idnum++; + print STDERR "DEST: bumped idnum to $idnum\n"; + } + + # this is the end of a phrase, add it to the english hash + $english{$id}=join("", @phrase); + } undef @phrase; + $id=""; } elsif($_ ne "\n") { # gather everything related to this phrase push @phrase, $_; + if($_ =~ /^ *\/i) { + $withindest=1; + } + elsif($withindest && ($_ =~ /^ *\<\/dest\>/i)) { + $withindest=0; + } + elsif($withindest && ($_ =~ / *([^:]+): *(.*)/)) { + my ($name, $val)=($1, $2); + $dest=""; # in case it is left untouched for when the + # model name isn't "our" + dest($_, $name, $val); + + print STDERR "DEST: \"$dest\" for $name / $id\n"; + + if($dest && ($dest ne "none")) { + $id = $maybeid; + print STDERR "DEST: use this id $id\n"; + } + } } if($_ =~ /^ *id: ([^ \t\n]+)/i) { - $id=$1; - # voice-only entries get a difference range - if($id =~ /^VOICE_/) { - # Assign an ID number to this entry - $idmap{$id}=$vidnum; - $vidnum++; - } - else { - # Assign an ID number to this entry - $idmap{$id}=$idnum; - $idnum++; - } + $maybeid=$1; } } close(ENG); -- cgit v1.2.3