From 12e528ccd9f8764e745a4b634cc1d4f798fe44d8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 2 Apr 2006 09:07:24 +0000 Subject: first take at -o for producing a friendly output for the voice-generating scripts git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9420 a1c6a512-1295-4272-9138-f99709370657 --- tools/genlang2 | 124 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 86 insertions(+), 38 deletions(-) diff --git a/tools/genlang2 b/tools/genlang2 index 7d82f21b31..07c866a288 100755 --- a/tools/genlang2 +++ b/tools/genlang2 @@ -44,6 +44,9 @@ Usage: genlang2 [options] Specify which target you want the translations/phrases for. Required when -b or -p is used. + -o + Voice mode output. Outputs all id: and voice: lines for the given target! + -v Enables verbose (debug) output. MOO @@ -69,19 +72,20 @@ my $binary = $b; my $update = $u; my $english = $e; +my $voiceout = $o; -my $check = ($binary?1:0) + ($prefix?1:0) + ($update?1:0); +my $check = ($binary?1:0) + ($prefix?1:0) + ($update?1:0) + ($voiceout?1:0); if($check > 1) { - print "Please use only one of -p, -u and -b\n"; + print "Please use only one of -p, -u, -o and -b\n"; exit; } if(!$check) { - print "Please use at least one of -p, -u and -b\n"; + print "Please use at least one of -p, -u, -o and -b\n"; exit; } -if(($binary || $update) && !$english) { - print "Please use -e too when you use -b or -u\n"; +if(($binary || $update || $voiceout) && !$english) { + print "Please use -e too when you use -b, -o or -u\n"; exit; } @@ -99,7 +103,6 @@ my %source; # id string to source phrase hash my %dest; # id string to dest phrase hash my %voice; # id string to voice phrase hash - my $input = $ARGV[0]; my @m; @@ -163,6 +166,7 @@ sub voice { parsetarget("voice", \$voice, @_); } +my %idmap; my %english; if($english) { # For the cases where the english file needs to be scanned/read, we do @@ -170,7 +174,7 @@ if($english) { # -u it is convenient. my $idnum=0; # start with a true number - my %idmap; + my $vidnum=0x8000; # first voice id open(ENG, "<$english") || die "can't open $english"; my @phrase; my $id; @@ -194,14 +198,17 @@ if($english) { if($_ =~ /^ *id: ([^ \t\n]+)/i) { $id=$1; - # Skip voice-only entries + # voice-only entries get a difference range if($id =~ /^VOICE_/) { - next; + # Assign an ID number to this entry + $idmap{$id}=$vidnum; + $vidnum++; + } + else { + # Assign an ID number to this entry + $idmap{$id}=$idnum; + $idnum++; } - - # Assign an ID number to this entry - $idmap{$id}=$idnum; - $idnum++; } } close(ENG); @@ -324,7 +331,7 @@ while() { if($dest =~ /^none\z/i) { # "none" as dest means that this entire phrase is to be # ignored - print "dest is NONE!\n"; + #print "dest is NONE!\n"; } else { @@ -432,11 +439,11 @@ extern unsigned char *language_strings[]; extern const unsigned char language_builtin[]; /* The enum below contains all available strings */ -enum { +enum \{ MOO ; -print CFILE <