diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/buildzip.pl | 1 | ||||
-rwxr-xr-x | tools/genlang | 60 |
2 files changed, 49 insertions, 12 deletions
diff --git a/tools/buildzip.pl b/tools/buildzip.pl index e2341f4252..70445570f8 100755 --- a/tools/buildzip.pl +++ b/tools/buildzip.pl | |||
@@ -683,6 +683,7 @@ STOP | |||
683 | 683 | ||
684 | # copy the already built lng files | 684 | # copy the already built lng files |
685 | glob_copy('apps/lang/*lng', "$temp_dir/langs/"); | 685 | glob_copy('apps/lang/*lng', "$temp_dir/langs/"); |
686 | glob_copy('apps/lang/*.zip', "$temp_dir/langs/"); | ||
686 | 687 | ||
687 | # copy the .lua files | 688 | # copy the .lua files |
688 | glob_mkdir("$temp_dir/rocks/viewers/lua/"); | 689 | glob_mkdir("$temp_dir/rocks/viewers/lua/"); |
diff --git a/tools/genlang b/tools/genlang index bfd9fac7b5..ac49e594d3 100755 --- a/tools/genlang +++ b/tools/genlang | |||
@@ -13,6 +13,7 @@ | |||
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 |
15 | my $LANGUAGE_COOKIE = 0x1a; | 15 | my $LANGUAGE_COOKIE = 0x1a; |
16 | my $VOICE_COOKIE = 0x9a; | ||
16 | my $LANGUAGE_VERSION = 0x06; | 17 | my $LANGUAGE_VERSION = 0x06; |
17 | my $LANGUAGE_FLAG_RTL = 0x01; | 18 | my $LANGUAGE_FLAG_RTL = 0x01; |
18 | 19 | ||
@@ -38,6 +39,10 @@ Usage: genlang [options] <langv2 file> | |||
38 | Make the tool create a binary language (.lng) file named [outfile]. | 39 | Make the tool create a binary language (.lng) file named [outfile]. |
39 | The use of this option requires that you also use -e, -t and -i. | 40 | The use of this option requires that you also use -e, -t and -i. |
40 | 41 | ||
42 | -c=<outfile> | ||
43 | Create binary voicestring file named [outfile]. Works like -b and can be | ||
44 | used the same time. | ||
45 | |||
41 | -u | 46 | -u |
42 | Update language file. Given the translated file and the most recent english | 47 | Update language file. Given the translated file and the most recent english |
43 | file, you\'ll get an updated version sent to stdout. Suitable action to do | 48 | file, you\'ll get an updated version sent to stdout. Suitable action to do |
@@ -89,18 +94,19 @@ my $prefix = $p; | |||
89 | my $binary = $b; | 94 | my $binary = $b; |
90 | my $update = $u; | 95 | my $update = $u; |
91 | my $sortfile = $s; | 96 | my $sortfile = $s; |
97 | my $binvoice = $c; | ||
92 | 98 | ||
93 | my $english = $e; | 99 | my $english = $e; |
94 | my $voiceout = $o; | 100 | my $voiceout = $o; |
95 | 101 | ||
96 | my $check = ($binary?1:0) + ($prefix?1:0) + ($update?1:0) + ($voiceout?1:0) + ($sortfile?1:0); | 102 | my $check = ($binary?.5:0) + ($prefix?1:0) + ($update?1:0) + ($voiceout?1:0) + ($sortfile?1:0) + ($binvoice?.5:0); |
97 | 103 | ||
98 | if($check > 1) { | 104 | if($check > 1) { |
99 | print STDERR "Please use only one of -p, -u, -o, -b and -s\n"; | 105 | print STDERR "Please use only one of -p, -u, -o, -b, -c and -s\n"; |
100 | exit; | 106 | exit; |
101 | } | 107 | } |
102 | if(!$check) { | 108 | if(!$check) { |
103 | print STDERR "Please use at least one of -p, -u, -o, -b and -s\n"; | 109 | print STDERR "Please use at least one of -p, -u, -o, -c, -e and -s\n"; |
104 | exit; | 110 | exit; |
105 | } | 111 | } |
106 | 112 | ||
@@ -724,7 +730,7 @@ MOO | |||
724 | close(HFILE_CORE); | 730 | close(HFILE_CORE); |
725 | close(CFILE_CORE); | 731 | close(CFILE_CORE); |
726 | } # end of the c/h file generation | 732 | } # end of the c/h file generation |
727 | elsif($binary) { | 733 | elsif($binary || $binvoice) { |
728 | # Creation of a binary lang file was requested | 734 | # Creation of a binary lang file was requested |
729 | 735 | ||
730 | # We must first scan the english file to get the correct order of the id | 736 | # We must first scan the english file to get the correct order of the id |
@@ -732,10 +738,18 @@ elsif($binary) { | |||
732 | # files. The english file is scanned before the translated file was | 738 | # files. The english file is scanned before the translated file was |
733 | # scanned. | 739 | # scanned. |
734 | 740 | ||
735 | open(OUTF, ">$binary") or die "Error: Can't create $binary"; | 741 | if($binary) { |
736 | binmode OUTF; | 742 | open(OUTF, ">$binary") or die "Error: Can't create $binary"; |
737 | printf OUTF ("%c%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id, | 743 | binmode OUTF; |
738 | $langoptions); # magic lang file header | 744 | printf OUTF ("%c%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id, |
745 | $langoptions); # magic lang file header | ||
746 | } | ||
747 | if($binvoice) { | ||
748 | open(OUTV, ">$binvoice") or die "Error: Can't create $binary"; | ||
749 | binmode OUTV; | ||
750 | printf OUTV ("%c%c%c%c", $VOICE_COOKIE, $LANGUAGE_VERSION, $target_id, | ||
751 | $langoptions); # magic lang file header | ||
752 | } | ||
739 | 753 | ||
740 | # output the number of strings for each user | 754 | # output the number of strings for each user |
741 | my $foffset = $HEADER_SIZE + $SUBHEADER_SIZE * keys(%users); | 755 | my $foffset = $HEADER_SIZE + $SUBHEADER_SIZE * keys(%users); |
@@ -744,18 +758,28 @@ elsif($binary) { | |||
744 | for $n (0 .. $idcount[$_]-1) { | 758 | for $n (0 .. $idcount[$_]-1) { |
745 | $size += length(trim($dest{$idnum[$_][$n]})) + 1; | 759 | $size += length(trim($dest{$idnum[$_][$n]})) + 1; |
746 | } | 760 | } |
747 | printf OUTF ("%c%c%c%c%c%c", ($idcount[$_] >> 8), ($idcount[$_] & 0xff), | 761 | if($binary) { |
748 | ($size >> 8), ($size & 0xff), ($foffset >> 8), ($foffset & 0xff)); | 762 | printf OUTF ("%c%c%c%c%c%c", ($idcount[$_] >> 8), ($idcount[$_] & 0xff), |
763 | ($size >> 8), ($size & 0xff), ($foffset >> 8), ($foffset & 0xff)); | ||
764 | } | ||
765 | if($binvoice) { | ||
766 | printf OUTV ("%c%c%c%c%c%c", ($idcount[$_] >> 8), ($idcount[$_] & 0xff), | ||
767 | ($size >> 8), ($size & 0xff), ($foffset >> 8), ($foffset & 0xff)); | ||
768 | } | ||
749 | $foffset += $size; | 769 | $foffset += $size; |
750 | } | 770 | } |
751 | 771 | ||
752 | for (keys %users) { | 772 | for (keys %users) { |
753 | # loop over the target phrases | 773 | # loop over the target phrases |
754 | for $n (0 .. $idcount[$_]-1) { | 774 | # This loops over the strings in the translated language file order |
775 | my @ids = ((0 .. ($idcount[$_]-1))); | ||
776 | push @ids, (0x8000 .. ($voiceid[$_]-1)); | ||
777 | for $n (@ids) { | ||
755 | my $name=$idnum[$_][$n]; # get the ID | 778 | my $name=$idnum[$_][$n]; # get the ID |
756 | my $dest = $dest{$name}; # get the destination phrase | 779 | my $dest = $dest{$name}; # get the destination phrase |
780 | my $voice = $voice{$name}; # get the destination voice string | ||
757 | 781 | ||
758 | if($dest) { | 782 | if($dest && $n < 0x8000 && $binary) { |
759 | $dest =~ s/^\"(.*)\"\s*$/$1/g; # cut off quotes | 783 | $dest =~ s/^\"(.*)\"\s*$/$1/g; # cut off quotes |
760 | 784 | ||
761 | # Now, make sure we get the number from the english sort order: | 785 | # Now, make sure we get the number from the english sort order: |
@@ -763,8 +787,20 @@ elsif($binary) { | |||
763 | 787 | ||
764 | printf OUTF ("%c%c%s\x00", ($idnum>>8), ($idnum&0xff), $dest); | 788 | printf OUTF ("%c%c%s\x00", ($idnum>>8), ($idnum&0xff), $dest); |
765 | } | 789 | } |
790 | if($voice && $binvoice) { | ||
791 | $voice =~ s/^\"(.*)\"\s*$/$1/g; # cut off quotes | ||
792 | # Now, make sure we get the number from the english sort order: | ||
793 | $idnum = $idmap[$_]{$name}; | ||
794 | printf OUTV ("%c%c%s\x00", ($idnum>>8), ($idnum&0xff), $voice); | ||
795 | } | ||
766 | } | 796 | } |
767 | } | 797 | } |
798 | if($binary) { | ||
799 | close(OUTF); | ||
800 | } | ||
801 | if($binvoice) { | ||
802 | close(OUTV); | ||
803 | } | ||
768 | } | 804 | } |
769 | elsif($voiceout) { | 805 | elsif($voiceout) { |
770 | # voice output requested, display id: and voice: strings in a v1-like | 806 | # voice output requested, display id: and voice: strings in a v1-like |