iPod: Remove/reduce the udelay()s in the button driver. They were in the IPL source...
[Rockbox.git] / tools / uplang
blob1cb3913c761f417b2a5b217554aae4d0a36bf287
1 #!/usr/bin/perl
3 if(!$ARGV[0]) {
4 print <<MOO
5 Usage: lang.pl <english file> <translated file>
6 MOO
8 exit;
11 my %ids, @ids;
12 open(ENG, "<$ARGV[0]");
13 while(<ENG>) {
14 if($_ =~ /^ *\#/) {
15 # comment
16 next;
18 $_ =~ s/\r//g;
19 if($_ =~ /^ *([a-z]+): *(.*)/) {
20 ($var, $value) = ($1, $2);
21 # print "$var => $value\n";
23 $set{$var} = $value;
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'};
31 $ids{$set{'id'}}=1;
32 push @ids, $set{'id'};
33 undef %set;
37 close(ENG);
39 undef %set;
40 my $cblock = 1;
41 open(NEW, "<$ARGV[1]");
42 while(<NEW>) {
43 $_ =~ s/\r//g;
45 if($_ =~ /^ *\#/) {
46 # comment
47 if($_ !~ /^ *\#\#\#/) {
48 # no special ### comment -> keep it
49 if(!$cblock) {
50 print "\n";
51 $cblock = 1;
53 print $_;
55 next;
57 $cblock = 0;
59 if($_ =~ /^ *([a-z]+): *(.*)/) {
60 ($var, $value) = ($1, $2);
62 $set{$var} = $value;
64 if($var eq "new") {
65 # the last one for a single phrase
67 if(!$ids{$set{'id'}}) {
68 print "\n### ".$set{'id'}." was not found in the english file!\n";
69 next;
72 print "\nid: ".$set{'id'}."\n";
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";
79 else {
80 print "desc: ".$set{'desc'}."\n";
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";
88 else {
89 print "eng: ".$set{'eng'}."\n";
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'};
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'};
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'};
114 print "voice: ".$set{'voice'}."\n";
116 print "new: ".$set{'new'}."\n";
118 $ids{$set{'id'}}=0;
119 undef %set;
123 close(NEW);
125 # output new phrases not already translated , in english.lang order
126 for(@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";