When we read the year from the RTC, it can be so totally messed up so that
[kugel-rb.git] / tools / uplang
blob41730fb3d324c54451e1c9a33c7c161b8a3e09f9
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;
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'};
30 $ids{$set{'id'}}=1;
31 undef %set;
35 close(ENG);
37 undef %set;
38 open(NEW, "<$ARGV[1]");
39 while(<NEW>) {
40 if($_ =~ /^ *\#/) {
41 # comment
42 next;
44 $_ =~ s/\r//g;
46 if($_ =~ /^ *([a-z]+): *(.*)/) {
47 ($var, $value) = ($1, $2);
49 $set{$var} = $value;
51 if($var eq "new") {
52 # the last one for a single phrase
54 if(!$ids{$set{'id'}}) {
55 print "### ".$set{'id'}." was not found in the english file!\n";
56 next;
59 print "\nid: ".$set{'id'}."\n";
62 if($set{'desc'} ne $all{$set{'id'}, 'desc'}) {
63 print "### Description changed! Previous description was:\n",
64 "### \"".$set{'desc'}."\"\n";
65 $set{'desc'} = $all{$set{'id'}, 'desc'};
68 print "desc: ".$set{'desc'}."\n";
69 if($set{'eng'} ne $all{$set{'id'}, 'eng'}) {
70 print "### English phrase was changed! Previous translation was made on:\n",
71 "### ".$set{'eng'}."\n";
72 $set{'eng'} = $all{$set{'id'}, 'eng'};
74 print "eng: ".$set{'eng'}."\n";
75 print "new: ".$set{'new'}."\n";
77 $ids{$set{'id'}}=0;
81 close(NEW);
83 # output new phrases not already translated
84 for(sort keys %ids) {
85 if($ids{$_}) {
86 my $id=$_;
87 print "\nid: $_\n";
88 print "desc: ".$all{$id, 'desc'}."\n";
89 print "eng: ".$all{$id, 'eng'}."\n";
90 print "### Not previously translated\n";
91 print "new: \n";