2 ############################################################################
4 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
11 # Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
13 # All files in this archive are subject to the GNU General Public License.
14 # See the file COPYING in the source tree root for full license agreement.
16 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 # KIND, either express or implied.
19 ############################################################################
21 if(!$ARGV[0] || !$ARGV[1] || !$ARGV[2]) {
23 Usage: binlang <english file> <language file> <output file>
25 Generate a binary language file.
31 if($ARGV[0] eq "-v") {
36 my $english = $ARGV[0];
38 my $output = $ARGV[2];
42 open(ENG
, "<$english") or die "Can't open $english";
43 open(LANG
, "<$input") or die "Can't open $input";
44 open(OUTF
, ">$output") or die "Can't open $output";
50 printf OUTF
("\x1a%c", $langversion); # magic lang file header
53 # We scan the english file to get the correct order of the id numbers
55 my $idnum=0; # start with a true number
61 # get rid of DOS newlines
63 if($_ =~ /^ *([a-z]+): *(.*)/) {
64 ($var, $value) = ($1, $2);
67 # "new" is always the last one, so now we have them all
71 if($value =~ s/^\"(.*)\"\s*$/$1/g) {
72 # Skip voice-only entries
73 if(!$value && $set{'voice'} ne "\"\"") {
74 $idnum{$set{'id'}} = '_done_';
78 # Assign an ID number to this entry
79 $idnum{$set{'id'}}=$idnum;
93 # get rid of DOS newlines
95 if($_ =~ /^ *([a-z]+): *(.*)/) {
96 ($var, $value) = ($1, $2);
100 # "new" is always the last one, so now we have them all
102 $idnum = $idnum{$set{'id'}};
104 # Skip already processed entries (like voice-only ones)
105 next if($idnum eq '_done_');
108 # if not set, get the english version
109 $value = $set{'eng'};
112 if($value =~ s/^\"(.*)\"\s*$/$1/g) {
114 warn "Found no ".$set{'id'}." in english file!\n";
117 $idnum{$set{'id'}} = '_done_';
119 printf OUTF
("%c%c%s\x00",
120 ($idnum>>8), ($idnum&0xff),
123 printf("%02x => %s\n", $idnum, $value);
128 warn "String for ".$set{'id'}." misses quotes\n";
141 foreach $k (keys(%idnum))
143 if($idnum{$k} ne '_done_')
145 warn "Missing ID in $input: $k\n";