diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-07-27 17:12:20 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-07-27 17:20:59 -0400 |
commit | b9d13b898d6cb81f60eb819f53276a9ac1e11dad (patch) | |
tree | a66ff11175ea79aa87d402f60b0dd6771ef8451d | |
parent | acb9754c7c7f7dffa74012c4becbd8b8637986c7 (diff) | |
download | rockbox-b9d13b898d6cb81f60eb819f53276a9ac1e11dad.tar.gz rockbox-b9d13b898d6cb81f60eb819f53276a9ac1e11dad.zip |
genlang: strip out the '-u' mode as it's now handled by updatelang
Change-Id: Ic05cc72282cc016048e292ee0bef41c38148af8c
-rwxr-xr-x | tools/genlang | 131 |
1 files changed, 8 insertions, 123 deletions
diff --git a/tools/genlang b/tools/genlang index e943492067..893badb57e 100755 --- a/tools/genlang +++ b/tools/genlang | |||
@@ -43,11 +43,6 @@ Usage: genlang [options] <langv2 file> | |||
43 | Create binary voicestring file named [outfile]. Works like -b and can be | 43 | Create binary voicestring file named [outfile]. Works like -b and can be |
44 | used the same time. | 44 | used the same time. |
45 | 45 | ||
46 | -u | ||
47 | Update language file. Given the translated file and the most recent english | ||
48 | file, you\'ll get an updated version sent to stdout. Suitable action to do | ||
49 | when you intend to update a translation. | ||
50 | |||
51 | -e=<english lang file> | 46 | -e=<english lang file> |
52 | Point out the english (original source) file, to use that as master | 47 | Point out the english (original source) file, to use that as master |
53 | language template. Used in combination with -b, -u or -s. | 48 | language template. Used in combination with -b, -u or -s. |
@@ -92,26 +87,25 @@ MOO | |||
92 | 87 | ||
93 | my $prefix = $p; | 88 | my $prefix = $p; |
94 | my $binary = $b; | 89 | my $binary = $b; |
95 | my $update = $u; | ||
96 | my $sortfile = $s; | 90 | my $sortfile = $s; |
97 | my $binvoice = $c; | 91 | my $binvoice = $c; |
98 | 92 | ||
99 | my $english = $e; | 93 | my $english = $e; |
100 | my $voiceout = $o; | 94 | my $voiceout = $o; |
101 | 95 | ||
102 | my $check = ($binary?.5:0) + ($prefix?1:0) + ($update?1:0) + ($voiceout?1:0) + ($sortfile?1:0) + ($binvoice?.5:0); | 96 | my $check = ($binary?.5:0) + ($prefix?1:0) + ($voiceout?1:0) + ($sortfile?1:0) + ($binvoice?.5:0); |
103 | 97 | ||
104 | if($check > 1) { | 98 | if($check > 1) { |
105 | print STDERR "Please use only one of -p, -u, -o, -b, -c and -s\n"; | 99 | print STDERR "Please use only one of -p, -o, -b, -c and -s\n"; |
106 | exit; | 100 | exit; |
107 | } | 101 | } |
108 | if(!$check) { | 102 | if(!$check) { |
109 | print STDERR "Please use at least one of -p, -u, -o, -c, -e and -s\n"; | 103 | print STDERR "Please use at least one of -p, -o, -c, -e and -s\n"; |
110 | exit; | 104 | exit; |
111 | } | 105 | } |
112 | 106 | ||
113 | 107 | ||
114 | if(($binary || $update || $voiceout || $sortfile) && !$english) { | 108 | if(($binary || $voiceout || $sortfile) && !$english) { |
115 | print STDERR "Please use -e too when you use -b, -o, -u or -s\n"; | 109 | print STDERR "Please use -e too when you use -b, -o, -u or -s\n"; |
116 | exit; | 110 | exit; |
117 | } | 111 | } |
@@ -123,7 +117,7 @@ if($binary && !$target_id) { | |||
123 | } | 117 | } |
124 | 118 | ||
125 | my $target = $t; | 119 | my $target = $t; |
126 | if(!$target && !$update && !$sortfile) { | 120 | if(!$target && !$sortfile) { |
127 | print STDERR "Please specify a target (with -t)!\n"; | 121 | print STDERR "Please specify a target (with -t)!\n"; |
128 | exit; | 122 | exit; |
129 | } | 123 | } |
@@ -310,7 +304,7 @@ sub readenglish { | |||
310 | elsif($withindest && ($_ =~ /^ *\<\/dest\>/i)) { | 304 | elsif($withindest && ($_ =~ /^ *\<\/dest\>/i)) { |
311 | $withindest=0; | 305 | $withindest=0; |
312 | 306 | ||
313 | if($update || ($deststr && ($deststr !~ /^none\z/i))) { | 307 | if($deststr && ($deststr !~ /^none\z/i)) { |
314 | # we unconditionally always use all IDs when the "update" | 308 | # we unconditionally always use all IDs when the "update" |
315 | # feature is used | 309 | # feature is used |
316 | $id = $maybeid; | 310 | $id = $maybeid; |
@@ -349,83 +343,6 @@ sub readenglish { | |||
349 | close(ENG); | 343 | close(ENG); |
350 | } | 344 | } |
351 | 345 | ||
352 | # a function that compares the english phrase with the translated one. | ||
353 | # compare source strings and desc | ||
354 | |||
355 | # Then output the updated version! | ||
356 | sub compare { | ||
357 | my ($idstr, $engref, $locref)=@_; | ||
358 | my ($edesc, $ldesc); | ||
359 | my ($esource, $lsource); | ||
360 | my $mode=0; | ||
361 | |||
362 | for my $l (@$engref) { | ||
363 | if($l =~ /^ *#/) { | ||
364 | # comment | ||
365 | next; | ||
366 | } | ||
367 | if($l =~ /^ *desc: (.*)/) { | ||
368 | $edesc=$1; | ||
369 | } | ||
370 | elsif($l =~ / *\<source\>/i) { | ||
371 | $mode=1; | ||
372 | } | ||
373 | elsif($mode) { | ||
374 | if($l =~ / *\<\/source\>/i) { | ||
375 | last; | ||
376 | } | ||
377 | $esource .= "$l\n"; | ||
378 | } | ||
379 | } | ||
380 | |||
381 | my @show; | ||
382 | my @source; | ||
383 | |||
384 | $mode = 0; | ||
385 | for my $l (@$locref) { | ||
386 | if($l =~ /^ *desc: (.*)/) { | ||
387 | $ldesc=$1; | ||
388 | if(trim($edesc) ne trim($ldesc)) { | ||
389 | $l = "### The 'desc' field differs from the english!\n### the previously used desc is commented below:\n### desc: $ldesc\n desc: $edesc\n"; | ||
390 | } | ||
391 | push @show, $l; | ||
392 | } | ||
393 | elsif($l =~ / *\<source\>/i) { | ||
394 | $mode=1; | ||
395 | push @show, $l; | ||
396 | } | ||
397 | elsif($mode) { | ||
398 | if($l =~ / *\<\/source\>/i) { | ||
399 | $mode = 0; | ||
400 | print @show; | ||
401 | if(trim($esource) ne trim($lsource)) { | ||
402 | print "### The <source> section differs from the english!\n", | ||
403 | "### the previously used one is commented below:\n"; | ||
404 | for(split("\n", $lsource)) { | ||
405 | print "### $_\n"; | ||
406 | } | ||
407 | print $esource; | ||
408 | } | ||
409 | else { | ||
410 | print $lsource; | ||
411 | } | ||
412 | undef @show; # start over | ||
413 | |||
414 | push @show, $l; | ||
415 | } | ||
416 | else { | ||
417 | $lsource .= "$l"; | ||
418 | } | ||
419 | } | ||
420 | else { | ||
421 | push @show, $l; | ||
422 | } | ||
423 | } | ||
424 | |||
425 | |||
426 | print @show; | ||
427 | } | ||
428 | |||
429 | my @idcount; # counter for lang ID numbers | 346 | my @idcount; # counter for lang ID numbers |
430 | my @voiceid; # counter for voice-only ID numbers | 347 | my @voiceid; # counter for voice-only ID numbers |
431 | 348 | ||
@@ -452,7 +369,7 @@ while(<LANG>) { | |||
452 | 369 | ||
453 | if($_ =~ /^( *\#|[ \t\n\r]*\z)/) { | 370 | if($_ =~ /^( *\#|[ \t\n\r]*\z)/) { |
454 | # comment or empty line - output it if it's part of the header | 371 | # comment or empty line - output it if it's part of the header |
455 | if ($header and ($update || $sortfile)) { | 372 | if ($header and $sortfile) { |
456 | print($_); | 373 | print($_); |
457 | } | 374 | } |
458 | next; | 375 | next; |
@@ -490,10 +407,7 @@ while(<LANG>) { | |||
490 | elsif($sortfile) { | 407 | elsif($sortfile) { |
491 | $allphrases{$idstr}=join('',@phrase); | 408 | $allphrases{$idstr}=join('',@phrase); |
492 | } | 409 | } |
493 | elsif(!$update) { | 410 | else { |
494 | # we don't do the fully detailed analysis when we "update" | ||
495 | # since we don't do it for a particular target etc | ||
496 | |||
497 | # allow the keyword 'deprecated' to be used on dest and | 411 | # allow the keyword 'deprecated' to be used on dest and |
498 | # voice strings to mark that as deprecated. It will then | 412 | # voice strings to mark that as deprecated. It will then |
499 | # be replaced with "". | 413 | # be replaced with "". |
@@ -569,22 +483,6 @@ while(<LANG>) { | |||
569 | undef $user; | 483 | undef $user; |
570 | undef %phrase; | 484 | undef %phrase; |
571 | } | 485 | } |
572 | |||
573 | if($update) { | ||
574 | my $e = $english{$idstr}; | ||
575 | |||
576 | if($e) { | ||
577 | # compare original english with this! | ||
578 | my @eng = split("\n", $english{$idstr}); | ||
579 | |||
580 | compare($idstr, \@eng, \@phrase); | ||
581 | |||
582 | $english{$idstr}=""; # clear it | ||
583 | } | ||
584 | else { | ||
585 | print "### $idstr: The phrase is not used. Skipped\n"; | ||
586 | } | ||
587 | } | ||
588 | undef @phrase; | 486 | undef @phrase; |
589 | } # end of </phrase> | 487 | } # end of </phrase> |
590 | elsif($part eq "/options") { | 488 | elsif($part eq "/options") { |
@@ -613,19 +511,6 @@ while(<LANG>) { | |||
613 | } | 511 | } |
614 | close(LANG); | 512 | close(LANG); |
615 | 513 | ||
616 | if($update) { | ||
617 | my $any=0; | ||
618 | for(keys %english) { | ||
619 | if($english{$_}) { | ||
620 | print "###\n", | ||
621 | "### This phrase below was not present in the translated file\n", | ||
622 | "<phrase>\n"; | ||
623 | print $english{$_}; | ||
624 | print "</phrase>\n"; | ||
625 | } | ||
626 | } | ||
627 | } | ||
628 | |||
629 | if ($sortfile) { | 514 | if ($sortfile) { |
630 | for(sort { $sortorder{$a} <=> $sortorder{$b} } keys %allphrases) { | 515 | for(sort { $sortorder{$a} <=> $sortorder{$b} } keys %allphrases) { |
631 | print $allphrases{$_}; | 516 | print $allphrases{$_}; |