diff options
Diffstat (limited to 'tools/genlang')
-rwxr-xr-x | tools/genlang | 54 |
1 files changed, 10 insertions, 44 deletions
diff --git a/tools/genlang b/tools/genlang index 45f7bc82d9..6d0aa12528 100755 --- a/tools/genlang +++ b/tools/genlang | |||
@@ -21,14 +21,6 @@ my $LANGUAGE_FLAG_UNITS_FIRST = 0x02; | |||
21 | my $HEADER_SIZE = 4; | 21 | my $HEADER_SIZE = 4; |
22 | my $SUBHEADER_SIZE = 6; | 22 | my $SUBHEADER_SIZE = 6; |
23 | 23 | ||
24 | # A note for future users and readers: The original v1 language system allowed | ||
25 | # the build to create and use a different language than english built-in. We | ||
26 | # removed that feature from our build-system, but the build scripts still had | ||
27 | # the ability. But, starting now, this ability is no longer provided since I | ||
28 | # figured it was boring and unnecessary to write support for now since we | ||
29 | # don't use it anymore. | ||
30 | |||
31 | |||
32 | if(!$ARGV[0]) { | 24 | if(!$ARGV[0]) { |
33 | print <<MOO | 25 | print <<MOO |
34 | Usage: genlang [options] <langv2 file> | 26 | Usage: genlang [options] <langv2 file> |
@@ -46,11 +38,7 @@ Usage: genlang [options] <langv2 file> | |||
46 | 38 | ||
47 | -e=<english lang file> | 39 | -e=<english lang file> |
48 | Point out the english (original source) file, to use that as master | 40 | Point out the english (original source) file, to use that as master |
49 | language template. Used in combination with -b, -u or -s. | 41 | language template. Used in combination with -b. |
50 | |||
51 | -s | ||
52 | Sort the Update language file in the same order as the strings in the | ||
53 | English file. | ||
54 | 42 | ||
55 | -t=<target> | 43 | -t=<target> |
56 | Specify which target you want the translations/phrases for. Required when | 44 | Specify which target you want the translations/phrases for. Required when |
@@ -73,41 +61,26 @@ MOO | |||
73 | exit; | 61 | exit; |
74 | } | 62 | } |
75 | 63 | ||
76 | # How update works: | ||
77 | # | ||
78 | # 1) scan the english file, keep the whole <phrase> for each phrase. | ||
79 | # 2) read the translated file, for each end of phrase, compare: | ||
80 | # A) all source strings, if there's any change there should be a comment about | ||
81 | # it output | ||
82 | # B) the desc fields | ||
83 | # | ||
84 | # 3) output the phrase with the comments from above | ||
85 | # 4) check which phrases that the translated version didn't have, and spit out | ||
86 | # the english version of those | ||
87 | # | ||
88 | |||
89 | my $prefix = $p; | 64 | my $prefix = $p; |
90 | my $binary = $b; | 65 | my $binary = $b; |
91 | my $sortfile = $s; | ||
92 | my $binvoice = $c; | 66 | my $binvoice = $c; |
93 | 67 | ||
94 | my $english = $e; | 68 | my $english = $e; |
95 | my $voiceout = $o; | 69 | my $voiceout = $o; |
96 | 70 | ||
97 | my $check = ($binary?.5:0) + ($prefix?1:0) + ($voiceout?1:0) + ($sortfile?1:0) + ($binvoice?.5:0); | 71 | my $check = ($binary?.5:0) + ($prefix?1:0) + ($voiceout?1:0) + ($binvoice?.5:0); |
98 | 72 | ||
99 | if($check > 1) { | 73 | if($check > 1) { |
100 | print STDERR "Please use only one of -p, -o, -b, -c and -s\n"; | 74 | print STDERR "Please use only one of -p, -o, -b, and -c\n"; |
101 | exit; | 75 | exit; |
102 | } | 76 | } |
103 | if(!$check) { | 77 | if(!$check) { |
104 | print STDERR "Please use at least one of -p, -o, -c, -e and -s\n"; | 78 | print STDERR "Please use at least one of -p, -o, -c, and -e\n"; |
105 | exit; | 79 | exit; |
106 | } | 80 | } |
107 | 81 | ||
108 | 82 | if(($binary || $voiceout) && !$english) { | |
109 | if(($binary || $voiceout || $sortfile) && !$english) { | 83 | print STDERR "Please use -e too when you use -b, or -o\n"; |
110 | print STDERR "Please use -e too when you use -b, -o, -u or -s\n"; | ||
111 | exit; | 84 | exit; |
112 | } | 85 | } |
113 | 86 | ||
@@ -118,7 +91,7 @@ if($binary && !$target_id) { | |||
118 | } | 91 | } |
119 | 92 | ||
120 | my $target = $t; | 93 | my $target = $t; |
121 | if(!$target && !$sortfile) { | 94 | if(!$target) { |
122 | print STDERR "Please specify a target (with -t)!\n"; | 95 | print STDERR "Please specify a target (with -t)!\n"; |
123 | exit; | 96 | exit; |
124 | } | 97 | } |
@@ -234,9 +207,8 @@ if($english) { | |||
234 | } | 207 | } |
235 | 208 | ||
236 | sub readenglish { | 209 | sub readenglish { |
237 | # For the cases where the english file needs to be scanned/read, we do | 210 | # For the cases where the english file needs to be scanned/read, we must |
238 | # it before we read the translated file. For -b it isn't necessary, but for | 211 | # do it before we read the translated file. |
239 | # -u it is convenient. | ||
240 | 212 | ||
241 | my @idnum = ((0)); # start with a true number | 213 | my @idnum = ((0)); # start with a true number |
242 | my @vidnum = ((0x8000)); # first voice id | 214 | my @vidnum = ((0x8000)); # first voice id |
@@ -318,7 +290,7 @@ sub readenglish { | |||
318 | elsif($withindest && ($_ =~ / *([^:]+): *(.*)/)) { | 290 | elsif($withindest && ($_ =~ / *([^:]+): *(.*)/)) { |
319 | my ($name, $val)=($1, $2); | 291 | my ($name, $val)=($1, $2); |
320 | $dest=""; # in case it is left untouched for when the | 292 | $dest=""; # in case it is left untouched for when the |
321 | # model name isn't "our" | 293 | # model name isn't "ours" |
322 | dest($_, $name, $val); | 294 | dest($_, $name, $val); |
323 | 295 | ||
324 | if($dest) { | 296 | if($dest) { |
@@ -358,7 +330,6 @@ for (keys %users) { | |||
358 | 330 | ||
359 | open(LANG, "<$input") || die "Error: couldn't read language file named $input\n"; | 331 | open(LANG, "<$input") || die "Error: couldn't read language file named $input\n"; |
360 | my @phrase; | 332 | my @phrase; |
361 | my $header = 1; | ||
362 | my $langoptions = 0; | 333 | my $langoptions = 0; |
363 | 334 | ||
364 | while(<LANG>) { | 335 | while(<LANG>) { |
@@ -376,13 +347,8 @@ while(<LANG>) { | |||
376 | if ($_ =~ /LANGUAGE_UNITS_FIRST/) { | 347 | if ($_ =~ /LANGUAGE_UNITS_FIRST/) { |
377 | $langoptions |= $LANGUAGE_FLAG_UNITS_FIRST; | 348 | $langoptions |= $LANGUAGE_FLAG_UNITS_FIRST; |
378 | } | 349 | } |
379 | |||
380 | if ($header and $sortfile) { | ||
381 | print($_); | ||
382 | } | ||
383 | next; | 350 | next; |
384 | } | 351 | } |
385 | $header = 0; | ||
386 | 352 | ||
387 | my $ll = $_; | 353 | my $ll = $_; |
388 | 354 | ||