first cut of the new, shiny...
Andrew Lewman authored 13 years ago
|
1) ## translation metadata
2) # Revision: $Revision: 21313 $
3)
4) # Note to translators:
5) # translating this page is probably not a good idea, and it never was intended to be translated.
6) # it contains lots of programming logic, which you would have to duplicate, and it's probably
7) # useful only to other translators which most likely will know a bit of english.
8) #
9) # Thanks for your hard work, improve the other pages instead. :) -- weasel
10) #include "head.wmi" TITLE="Tor Projecdt: Translation status" CHARSET="UTF-8"
11) #use "functions.wmi"
12)
13) <div id="content" class="clearfix">
14) <div id="breadcrumbs">
|
first cut of the new, shiny...
Andrew Lewman authored 13 years ago
|
16) <a href="<page getinvolved/getinvolved>">Get Involved » </a>
17) <a href="<page getinvolved/translation-status>">Translation Status</a>
18) </div>
19) <div id="maincol">
20) <h1>Tor: Translation status</h1>
21) <hr />
22)
23) <:
24) sub do_status(\%$$) {
25) my $dir = $_[1];
26) my $may_miss_dir = $_[2];
27) my %files;
28)
29) my @warnings;
30) for my $lang (@LANGUAGES) {
31) my $dir_opened = opendir(DIR, "$dir/$lang");
32)
33) if (! $dir_opened) {
34) $may_miss_dir or die ("Cannot opendir $dir/$lang: $!\n");
35) next;
36) }
37)
38) my @files = grep { $_ ne '.' && $_ ne '..' &&
39) $_ !~ /tor-manual/i && $_ !~ /translation-status/i && $_ =~ m/^[^.]/ && -f "$dir/$lang/$_"} readdir(DIR);
40) closedir DIR;
41)
42) for my $file (@files) {
43) $files{$lang}->{$file}->{'all'} = getMetadata("$dir/$lang/$file");
44) if ($lang eq 'en') {
45) $files{$lang}->{$file}->{'rev'} = translation_get_masterrevision_file($dir, $file);
46) } else {
47) $files{$lang}->{$file}->{'based'} = translation_get_basedonrevision_langfile($dir, $lang, $file);
48) };
49) };
50) };
51) my %priorities;
52) for my $file (keys %{$files{'en'}}) {
53) my $p = $files{'en'}->{$file}->{'all'}->{'Translation-Priority'};
54) if (defined $p) {
55) $priorities{$p} = 1;
56) };
57) };
58) my @priorities = sort {$a cmp $b} keys %priorities;
59) push @priorities, 'none';
60)
61) my $HTMLBASE = (defined $ENV{'HTMLBASE'} ? $ENV{'HTMLBASE'} : 'https://www.torproject.org/') . ($dir eq '.' ? '' : $dir.'/');
62)
63) for my $priority (@priorities) {
64) for my $file (sort {$a cmp $b} keys %{$files{'en'}}) {
65) my $file_priority = $files{'en'}->{$file}->{'all'}->{'Translation-Priority'};
66) next if (defined $file_priority && $priority ne $file_priority);
67) next if (!defined $file_priority && $priority ne 'none');
68) my $path = ($dir eq '.' ? '' : $dir.'/') . $file;
69)
70) my $obs = file_is_obsolete($dir, 'en', $file);
71) my $validatorlink = '';
72) my $htmlfile = $file;
73) if ($htmlfile =~ s/\.wml/.html/) {
74) $validatorlink = sprintf '<br><a href="http://validator.w3.org/check?uri=%s%s.en">validator</a>',
75) $HTMLBASE, $htmlfile;
76) };
77)
78) my $cell_path = sprintf '<th>%s</th>', $path;
79) my $cell_en = sprintf '<td%s>Revision %s%s<br>
80) <a href="https://svn.torproject.org/cgi-bin/viewvc.cgi/website/trunk/%sen/%s?root=Tor&view=markup">HEAD</a>
81) %s',
82) ($obs ? ' bgcolor="#D3D3D3"' : ''),
83) $files{'en'}->{$file}->{'rev'},
84) ($obs ? ' (obsolete)' :''),
85) ($dir eq '.' ? '' : $dir.'/'),
86) $file,
87) $validatorlink;
88)
89) ${$_[0]}{$priority}->{$path}->{'data'} = $cell_path . $cell_en;
90) # Assign high urgency if it's *.wmi, else init to 0
91) if ($file =~ /.wmi$/) {
92) ${$_[0]}{$priority}->{$path}->{'urgency'} = 1000;
93) } else {
94) ${$_[0]}{$priority}->{$path}->{'urgency'} = 0;
95) }
96)
97) for my $lang (@LANGUAGES) {
98) next if $lang eq 'en';
99) my $color;
100) my $status;
101) #my $path = ($dir eq '.' ? '' : $dir.'/') . $file;
102) if ($validatorlink) {
103) $validatorlink = sprintf '<br><a href="http://validator.w3.org/check?uri=%s%s.%s">validator</a>',
104) $HTMLBASE, $htmlfile, $lang;
105) };
106) if (exists $files{$lang}->{$file}) {
107) my $all_info = '';
108) for my $key (sort {$a cmp $b} keys %{$files{$lang}->{$file}->{'all'}}) {
109) next if $key eq 'Translation-Priority';
110) $all_info .= sprintf "%s: %s<br>", $key, $files{$lang}->{$file}->{'all'}->{$key};
111) };
112)
113) my $difflink;
114) if ($files{$lang}->{$file}->{'based'} eq $files{'en'}->{$file}->{'rev'}) {
115) $color='#90EE90';
116) $status='current';
117) $difflink='';
118) } else {
119) $status='not current';
120) if ($files{$lang}->{$file}->{'based'} ne 'unknown') {
121) $difflink=sprintf '<br><a href="https://svn.torproject.org/cgi-bin/viewvc.cgi/website/trunk/%sen/%s?root=Tor&r1=%s&r2=%s">changes in original</a>',
122) ($dir eq '.' ? '' : $dir.'/'), $file, $files{$lang}->{$file}->{'based'}, $files{'en'}->{$file}->{'rev'};
123) $color='yellow';
124) } else {
125) $difflink='';
126) $color='#FFA500';
127) };
128)
129) ${$_[0]}{$priority}->{$path}->{'urgency'} += 1;
130) };
131)
132) ${$_[0]}{$priority}->{$path}->{'data'} .= sprintf '<td bgcolor="%s">%s<br>
133) <a href="https://svn.torproject.org/cgi-bin/viewvc.cgi/website/trunk/%s%s/%s?root=Tor&view=markup">HEAD</a><br>
134) %s
135) %s
136) %s</td>',
137) $color,
138) $status,
139) ($dir eq '.' ? '' : $dir.'/'),
140) $lang, $file,
141) $all_info,
142) $difflink,
143) $validatorlink;
144) } else {
145) #my $path = ($dir eq '.' ? '' : $dir.'/') . $file;
146) $color=(($obs or $priority eq 'none') ?
147) '#90EE90' : 'red');
148) $status='missing';
149)
150) ${$_[0]}{$priority}->{$path}->{'data'} .= sprintf '<td bgcolor="%s">%s</td>', $color, $status;
151) ${$_[0]}{$priority}->{$path}->{'urgency'} += ($obs or $priority eq 'none') ? 0 : 2;
152) };
153) delete $files{$lang}->{$file};
154) };
155)
156) ${$_[0]}{$priority}->{$path}->{'data'} .= $cell_en . $cell_path;
157) };
158) };
159)
160) for my $lang (@LANGUAGES) {
161) next if $lang eq 'en';
162) if (keys %{$files{$lang}} > 0) {
163) # print "<p>";
164) print "<br><br>";
165) printf "<h2>Additional files in %s (%s)</h2>\n", $lang, $LANGUAGES{$lang};
166)
167) print "<table border=1>\n";
168) print "<tr>\n";
169) print "<th>File</th>\n";
170) print "<th>Based on Revision</th>\n";
171) print "</tr>\n";
172) for my $file (sort {$a cmp $b} keys %{$files{$lang}}) {
173) print "<tr>";
174) printf "<th>%s</th><td>", $file;
175) for my $key (sort {$a cmp $b} keys %{$files{$lang}->{$file}->{'all'}}) {
176) printf "%s: %s<br>", $key, $files{$lang}->{$file}->{'all'}->{$key};
177) };
178) printf "</td>";
179) delete $files{$lang}->{$file};
180) print "</tr>\n";
181) };
182) print "</table>\n\n";
183) };
184) };
185) };
186)
187) sub sort_and_print(\%) {
188) my %rows = %{$_[0]};
189)
190) for my $priority (sort {$a cmp $b} keys %rows) {
191) print "<h2>Translation priority: $priority</h2>\n";
192)
193) print "<table border=1>\n";
194) print "<tr>\n";
195) print "<th>File</th>\n";
196) printf("<th>%s (%s)</th>\n", $_, $LANGUAGES{$_}) for ('en', grep({ $_ ne 'en' } @LANGUAGES), 'en');
197) print "<th>File</th>\n";
198) print "</tr>\n";
199)
200) for my $row (sort {$rows{$priority}->{$b}->{'urgency'} <=> $rows{$priority}->{$a}->{'urgency'}} keys %{$rows{$priority}}) {
201) print "<tr>";
202) print $rows{$priority}->{$row}->{'data'};
203) delete ${$_[0]}{$priority}->{$row};
204) print "</tr>\n\n";
205) };
206)
207) print "</table><br>\n\n\n";
208) };
209) };
210)
211) # accumulate the table rows, then sort and print them
212) my %table_rows;
213) do_status(%table_rows, '.', 0);
214) do_status(%table_rows, 'docs', 1);
|