summaryrefslogtreecommitdiff
path: root/tools/genlang
diff options
context:
space:
mode:
Diffstat (limited to 'tools/genlang')
-rwxr-xr-xtools/genlang24
1 files changed, 20 insertions, 4 deletions
diff --git a/tools/genlang b/tools/genlang
index d191a820a6..44dfcc6fdf 100755
--- a/tools/genlang
+++ b/tools/genlang
@@ -13,7 +13,8 @@
13# See apps/language.c (TODO: Use common include for both) 13# See apps/language.c (TODO: Use common include for both)
14# Cookie and binary version for the binary lang file 14# Cookie and binary version for the binary lang file
15my $LANGUAGE_COOKIE = 0x1a; 15my $LANGUAGE_COOKIE = 0x1a;
16my $LANGUAGE_VERSION = 0x04; 16my $LANGUAGE_VERSION = 0x05;
17my $LANGUAGE_FLAG_RTL = 0x01;
17 18
18# A note for future users and readers: The original v1 language system allowed 19# A note for future users and readers: The original v1 language system allowed
19# the build to create and use a different language than english built-in. We 20# the build to create and use a different language than english built-in. We
@@ -167,6 +168,12 @@ sub phrase {
167 $phrase{$n}=$v; 168 $phrase{$n}=$v;
168} 169}
169 170
171my %options;
172sub options {
173 my ($full, $n, $v)=@_;
174 $options{$n}=$v;
175}
176
170sub parsetarget { 177sub parsetarget {
171 my ($debug, $strref, $full, $n, $v)=@_; 178 my ($debug, $strref, $full, $n, $v)=@_;
172 my $string; 179 my $string;
@@ -381,6 +388,8 @@ my $voiceid=0x8000; # counter for voice-only ID numbers
381open(LANG, "<$input") || die "Error: couldn't read language file named $input\n"; 388open(LANG, "<$input") || die "Error: couldn't read language file named $input\n";
382my @phrase; 389my @phrase;
383my $header = 1; 390my $header = 1;
391my $langoptions = 0;
392
384while(<LANG>) { 393while(<LANG>) {
385 394
386 $line++; 395 $line++;
@@ -510,9 +519,15 @@ while(<LANG>) {
510 print "### $idstr: The phrase is not used. Skipped\n"; 519 print "### $idstr: The phrase is not used. Skipped\n";
511 } 520 }
512 } 521 }
513 undef @phrase;
514
515 } # end of </phrase> 522 } # end of </phrase>
523 elsif($part eq "/options") {
524 # closing the options
525 if ($options{'rtl'}) {
526 $langoptions |= $LANGUAGE_FLAG_RTL;
527 }
528 } # end of </options>
529
530 undef @phrase;
516 531
517 # starts with a slash, this _ends_ this section 532 # starts with a slash, this _ends_ this section
518 $m = pop @m; # get back old value, the previous level's tag 533 $m = pop @m; # get back old value, the previous level's tag
@@ -661,7 +676,8 @@ elsif($binary) {
661 676
662 open(OUTF, ">$binary") or die "Error: Can't create $binary"; 677 open(OUTF, ">$binary") or die "Error: Can't create $binary";
663 binmode OUTF; 678 binmode OUTF;
664 printf OUTF ("%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id); # magic lang file header 679 printf OUTF ("%c%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id,
680 $langoptions); # magic lang file header
665 681
666 # loop over the target phrases 682 # loop over the target phrases
667 for $i (1 .. $idcount) { 683 for $i (1 .. $idcount) {