source: tags/gsdl-2_30d-distribution/gsdl/macros/Chktrans.pl@ 2308

Last change on this file since 2308 was 1099, checked in by gwp, 24 years ago

This is a perl script that checks whether the english.dm macro file has been fully translated to other languages. For each (non-English) language, it lists the macros that are translated correctly and incorrectly, and the macros that are not translated.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1#! /usr/bin/perl -w
2
3use strict;
4
5my @languages = ("chinese", "french", "german", "maori");
6
7print "
8Chktrans.pl
9
10This file checks english.dm and english2.dm against
11translations made in other languages. It outputs
12 whether the translation exists in each language,
13 what macros override the English (default) macros
14 what macros have not been translated,
15 what additional macros exist.
16
17Current languages:
18";
19
20foreach my $l (@languages) {
21 print " $l\n";
22}
23
24print "\nReading english.dm\n";
25
26open(E, "<english.dm");
27
28my $line;
29my $count = 0;
30my %macro;
31
32while (<E>) {
33 chomp;
34 $line = $_;
35
36 next unless ($line =~ /^_\w+_ +\{/);
37
38 $line =~ s/ +\{.*//;
39 $macro{$line} = 1;
40 $count++;
41}
42
43print "Read $count macros.\n\n";
44
45my $file;
46
47foreach my $l (@languages) {
48 $file = "$l.dm";
49
50 print "=============================================\nLanguage: $l\n";
51
52 # make sure thwere is a translation for the language
53 if (!-e "$file") {
54 print "$file doesn't exist\n\n";
55 next;
56 }
57
58 # read the macros in this language
59 print "Reading $file\n";
60 open(L, "<$file");
61 my (%lm, %lmnew, %lr, %lrnew);
62 my $lc = 0;
63 while (<L>) {
64 chomp;
65 $line = $_;
66
67 next unless ($line =~ /^_\w+_/);
68 next unless ($line =~ /\{/);
69
70 $line =~ s/ +\{.*//;
71 # There are four types of macro, the combos of:
72 # With or without macro country code
73 # Present or not present in %macro
74 if ($line =~ /\[/) {
75 $line =~ s/ .*//;
76 if (defined($macro{$line})) {
77 $lm{$line} = $line;
78 } else {
79 $lmnew{$line} = $line;
80 }
81 } else {
82 if (defined($macro{$line})) {
83 $lr{$line} = $line;
84 } else {
85 $lrnew{$line} = $line;
86 }
87 }
88 $lc++;
89 }
90 close L;
91 print "Read $lc macros.\n\n";
92
93 # How many macros operate correctly
94 print (scalar keys %lm);
95 print" macros are translated from english to $l\n\n";
96
97 # What are the new macros?
98 if (scalar keys %lmnew) {
99 print (scalar keys %lmnew);
100 print" macros are new $l macros with no eqivalents in english.dm:\n";
101 foreach my $m (sort (keys (%lmnew))) {
102 print "$m ";
103 }
104 print "\n\n";
105 }
106
107 # What are the new macros?
108 if (scalar keys %lrnew) {
109 print (scalar keys %lrnew);
110 print" macros are new macros in english that do not appear in english.dm:\n";
111 foreach my $m (sort (keys (%lrnew))) {
112 print "$m ";
113 }
114 print "\n\n";
115 }
116
117 # Which languages override their english counterparts?
118 if (scalar keys %lr) {
119 print (scalar keys %lr);
120 print" macros override equivalents in english.dm ";
121 print"(It doesn't matter if you override macros like widths, heights, and URLs):\n";
122 foreach my $m (sort (keys (%lr))) {
123 print "$m ";
124 }
125 print "\n\n";
126 }
127
128 # Which macros in english.dm do not appear in the newfile?
129 my @missing = ();
130 foreach my $m (sort (keys (%macro))) {
131 next if defined($lm{$m});
132 push @missing, $m;
133 }
134 if (scalar @missing) {
135 print (scalar @missing);
136 print " macros in english.dm have no entry in $l.dm:\n";
137 foreach my $m (sort @missing) {
138 print "$m ";
139 }
140 print "\n\n";
141 }
142
143 print "\n";
144
145}
Note: See TracBrowser for help on using the repository browser.