summaryrefslogtreecommitdiff
path: root/tools/uplang
diff options
context:
space:
mode:
Diffstat (limited to 'tools/uplang')
-rwxr-xr-xtools/uplang135
1 files changed, 3 insertions, 132 deletions
diff --git a/tools/uplang b/tools/uplang
index 81c3a3acc5..0f0106f98d 100755
--- a/tools/uplang
+++ b/tools/uplang
@@ -1,136 +1,7 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2 2
3if(!$ARGV[0]) { 3print <<MOO
4 print <<MOO 4The tool formerly known as 'uplang' is no longer used. We now use
5Usage: uplang <english file> <translated file> 5genlang2 with the -u option to get updated language files.
6MOO 6MOO
7; 7;
8 exit;
9}
10
11my %ids, @ids;
12open(ENG, "<$ARGV[0]");
13while(<ENG>) {
14 if($_ =~ /^ *\#/) {
15 # comment
16 next;
17 }
18 $_ =~ s/\r//g;
19 if($_ =~ /^ *([a-z]+): *(.*)/) {
20 ($var, $value) = ($1, $2);
21 # print "$var => $value\n";
22
23 $set{$var} = $value;
24
25 if($var eq "new") {
26 # the last one for a single phrase
27 $all{$set{'id'}, 'desc'}=$set{'desc'};
28 $all{$set{'id'}, 'eng'}=$set{'eng'};
29 $all{$set{'id'}, 'voice'}=$set{'voice'};
30
31 $ids{$set{'id'}}=1;
32 push @ids, $set{'id'};
33 undef %set;
34 }
35 }
36}
37close(ENG);
38
39undef %set;
40my $cblock = 1;
41open(NEW, "<$ARGV[1]");
42while(<NEW>) {
43 $_ =~ s/\r//g;
44
45 if($_ =~ /^ *\#/) {
46 # comment
47 if($_ !~ /^ *\#\#\#/) {
48 # no special ### comment -> keep it
49 if(!$cblock) {
50 print "\n";
51 $cblock = 1;
52 }
53 print $_;
54 }
55 next;
56 }
57 $cblock = 0;
58
59 if($_ =~ /^ *([a-z]+): *(.*)/) {
60 ($var, $value) = ($1, $2);
61
62 $set{$var} = $value;
63
64 if($var eq "new") {
65 # the last one for a single phrase
66
67 if(!$ids{$set{'id'}}) {
68 print "\n### ".$set{'id'}." was not found in the english file!\n";
69 next;
70 }
71
72 print "\nid: ".$set{'id'}."\n";
73
74 if($set{'desc'} ne $all{$set{'id'}, 'desc'}) {
75 print "### Description changed! Previous description was:\n",
76 "### \"".$set{'desc'}."\"\n";
77 print "desc: ".$all{$set{'id'}, 'desc'}."\n";
78 }
79 else {
80 print "desc: ".$set{'desc'}."\n";
81 }
82
83 if($set{'eng'} ne $all{$set{'id'}, 'eng'}) {
84 print "### English phrase was changed! Previous translation was made on:\n",
85 "### ".$set{'eng'}."\n";
86 print "eng: ".$all{$set{'id'}, 'eng'}."\n";
87 }
88 else {
89 print "eng: ".$set{'eng'}."\n";
90 }
91
92 if($set{'id'} =~ /^VOICE_/) { # voice only, compare desc:
93 if($set{'desc'} ne $all{$set{'id'}, 'desc'}) {
94 print "### Voice only: description changed! Voice set to english. Previous voice was:\n",
95 "### ".$set{'voice'}."\n";
96 $set{'voice'} = $all{$set{'id'}, 'voice'};
97 }
98 }
99 else { # standard entry, compare eng:
100 if($set{'eng'} ne $all{$set{'id'}, 'eng'}
101 #only if either original or translated voice: is non-empty
102 and ($set{'voice'} !~ /^(\"\")? *$/
103 or $all{$set{'id'}, 'voice'} !~ /^(\"\")? *$/)) {
104 print "### English phrase was changed! Voice set to english. Previous voice was:\n",
105 "### ".$set{'voice'}."\n";
106 $set{'voice'} = $all{$set{'id'}, 'voice'};
107 }
108 }
109 if($set{'voice'} =~ /^(\"\")? *$/
110 and $all{$set{'id'}, 'voice'} !~ /^(\"\")? *$/) {
111 print "### Voice not found in previous translation. Set to english.\n";
112 $set{'voice'} = $all{$set{'id'}, 'voice'};
113 }
114 print "voice: ".$set{'voice'}."\n";
115
116 print "new: ".$set{'new'}."\n";
117
118 $ids{$set{'id'}}=0;
119 undef %set;
120 }
121 }
122}
123close(NEW);
124
125# output new phrases not already translated , in english.lang order
126for(@ids) {
127 if($ids{$_}) {
128 my $id=$_;
129 print "\nid: $_\n";
130 print "desc: ".$all{$id, 'desc'}."\n";
131 print "eng: ".$all{$id, 'eng'}."\n";
132 print "### Not previously translated\n";
133 print "voice: ".$all{$id, 'voice'}."\n";
134 print "new: \n";
135 }
136}