/[webwml]/webwml/stattrans.pl
ViewVC logotype

Contents of /webwml/stattrans.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.88 - (hide annotations) (download)
Tue Jun 2 21:46:10 2009 UTC (3 years, 11 months ago) by fjp
Branch: MAIN
Changes since 1.87: +1 -1 lines
File MIME type: text/plain
Display current version of original document for untranslated files

Helps to set the translation header correctly. Have not investigated
why some documents get an empty version.
1 joy 1.1 #! /usr/bin/perl
2    
3 joy 1.38 # webwml-stattrans - Debian web site translation statistics
4 joy 1.1 # Copyright (c) 2001 Martin Schulze <joey@debian.org> and others
5    
6     # This program is free software; you can redistribute it and/or modify
7     # it under the terms of the GNU General Public License as published by
8     # the Free Software Foundation; either version 2 of the License, or
9     # (at your option) any later version.
10    
11     # This program is distributed in the hope that it will be useful,
12     # but WITHOUT ANY WARRANTY; without even the implied warranty of
13     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     # GNU General Public License for more details.
15    
16     # You should have received a copy of the GNU General Public License
17     # along with this program; if not, write to the Free Software
18 djpig 1.69 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 joy 1.1
20     use POSIX qw(strftime);
21 joy 1.6 use Getopt::Std;
22 barbier 1.24
23     # These modules reside under webwml/Perl
24     use lib ($0 =~ m|(.*)/|, $1 or ".") ."/Perl";
25     use Local::Cvsinfo;
26     use Webwml::Langs;
27     use Webwml::TransCheck;
28     use Webwml::TransIgnore;
29    
30 joy 1.7 $| = 1;
31 joy 1.1
32 joy 1.37 $opt_h = "/org/www.debian.org/www/devel/website/stats";
33 joy 1.6 $opt_w = "/org/www.debian.org/webwml";
34 djpig 1.57 $opt_p = "*.(wml|src)";
35 joy 1.38 $opt_t = "Debian web site translation statistics";
36 joy 1.6 $opt_v = 0;
37 joy 1.12 $opt_d = "u";
38 joy 1.14 $opt_l = undef;
39 witch 1.72 $opt_b = ""; # Base URL, if not debian.org
40     getopts('h:w:b:p:t:vd:l:') || die;
41 barbier 1.24 # Replace filename globbing by Perl regexps
42 djpig 1.54 $opt_p =~ s/\./\\./g;
43 barbier 1.24 $opt_p =~ s/\?/./g;
44     $opt_p =~ s/\*/.*/g;
45     $opt_p =~ s/$/\$/g;
46 joy 1.1 %config = (
47 joy 1.6 'htmldir' => $opt_h,
48     'wmldir' => $opt_w,
49     'wmlpat' => $opt_p,
50     'title' => $opt_t,
51     'verbose' => $opt_v,
52 joy 1.36 'difftype'=> $opt_d,
53 joy 1.1 );
54    
55 barbier 1.24 my $l = Webwml::Langs->new($opt_w);
56     my %langs = $l->name_iso();
57    
58     my $transignore = Webwml::TransIgnore->new($opt_w);
59    
60     my $cvs = Local::Cvsinfo->new();
61     $cvs->options(
62     recursive => 1,
63     matchfile => [ $config{'wmlpat'} ],
64     skipdir => [ "template" ],
65     );
66     $cvs->readinfo("$config{'wmldir'}/english");
67     foreach (@{$transignore->global()}) {
68     $cvs->removefile("$config{'wmldir'}/english/$_");
69     }
70    
71     my $altcvs = Local::Cvsinfo->new();
72     $altcvs->options(
73     recursive => 1,
74     matchfile => [ $config{'wmlpat'} ],
75     skipdir => [ "template" ],
76     );
77    
78 joy 1.1 $max_versions = 5;
79     $min_versions = 1;
80    
81    
82     $date = strftime "%a %b %e %H:%M:%S %Y %z", localtime;
83    
84 barbier 1.24 my %original;
85 barbier 1.25 my %transversion;
86     my %version;
87 kraai 1.27 my %files;
88 bertol 1.70 my %sizes;
89 joy 1.1
90     # Count wml files in given directory
91     #
92     sub getwmlfiles
93     {
94     my $lang = shift;
95 joy 1.14 my $dir = "$config{'wmldir'}/$lang";
96 joy 1.1 my $cutfrom = length ($config{'wmldir'})+length($lang)+2;
97     my $count = 0;
98 bertol 1.70 my $size = 0;
99 joy 1.1 my $is_english = ($lang eq "english")?1:0;
100 djpig 1.55 my ( $file, $v );
101 barbier 1.24 my @listfiles;
102 joy 1.1
103 joy 1.7 print "$lang " if ($config{verbose});
104 jseidel 1.87 if (! -d "$dir") {
105     print "$0: can't find $dir! Skipping ...\n";
106     return;
107     }
108 barbier 1.24 if ($is_english) {
109     @listfiles = @{$cvs->files()};
110     } else {
111     $altcvs->reset();
112     $altcvs->readinfo($dir);
113     @listfiles = @{$altcvs->files()};
114     }
115     foreach my $f (@listfiles) {
116     $file = substr ($f, $cutfrom);
117     next if $transignore->is_global($file);
118 kraai 1.27 $files{$file} = 1;
119 joy 1.7 $wmlfiles{$lang} .= " " . $file;
120 djpig 1.57 my $transcheck = Webwml::TransCheck->new("$dir/$file");
121 barbier 1.25 if ($transcheck->revision()) {
122     $transversion{"$lang/$file"} = $transcheck->revision();
123     $original{"$lang/$file"} ||= $transcheck->original();
124     }
125 joy 1.1 if ($is_english) {
126 barbier 1.25 $version{"$lang/$file"} = $cvs->revision($f);
127     } else {
128     $version{"$lang/$file"} = $altcvs->revision($f);
129     if (!$transcheck->revision()) {
130 thuriaux 1.65 $transcheckenglish = Webwml::TransCheck->new("english/$file");
131     if (!$transcheckenglish->revision() and (-e "english/$file")) {
132     $transversion{"$lang/$file"} = "1.1";
133     $original{"$lang/$file"} = "english";
134     } else {
135     $original{"english/$file"} = $lang;
136     $transversion{"english/$file"} ||= "1.1";
137     }
138 barbier 1.24 }
139 joy 1.1 }
140 french 1.50 if ($transcheck->maintainer()) {
141     $maintainer{"$lang/$file"} = $transcheck->maintainer();
142     }
143 joy 1.1 $count++;
144 bertol 1.70 $sizes{$file} = (stat "".($original{"english/$file"}||"english")."/".$file)[7];
145     $size += $sizes{$file};
146 joy 1.1 }
147 joy 1.7 $wmlfiles{$lang} .= " ";
148     $wml{$lang} = $count;
149 bertol 1.70 $wml_s{$lang} = $size;
150 barbier 1.25 }
151 joy 1.1
152     sub get_color
153     {
154     my $percent = shift;
155    
156 kraai 1.17 if ($percent < 50) {
157     return sprintf ("#FF%02x00", (255/50) * $percent);
158 joy 1.1 } else {
159 kraai 1.17 return sprintf ("#%02xFF00", (255/50) * (100 - $percent));
160 joy 1.1 }
161     }
162    
163     sub check_translation
164     {
165     my ($translation, $version, $file) = @_;
166 djpig 1.55 my ( @version_numbers, $major_number, $last_number );
167     my ( @translation_numbers, $major_translated_number, $last_translated_number );
168 joy 1.1
169 djpig 1.55 if ( $version && $translation ) {
170 joy 1.1 @version_numbers = split /\./,$version;
171 djpig 1.55 $major_number = $version_numbers[0];
172 joy 1.1 $last_number = pop @version_numbers;
173     die "Invalid CVS revision for $file: $version\n"
174     unless ($major_number =~ /\d+/ && $last_number =~ /\d+/);
175    
176     @translation_numbers = split /\./,$translation;
177 djpig 1.55 $major_translated_number = $translation_numbers[0];
178 joy 1.1 $last_translated_number = pop @translation_numbers;
179     die "Invalid translation revision for $file: $translation\n"
180     unless ($major_translated_number =~ /\d+/ && $last_translated_number =~ /\d+/);
181    
182     # Here we compare the original version with the translated one and print
183     # a note for the user if their first or last numbers are too far apart
184     # From translation-check.wml
185    
186 djpig 1.55 if ( $major_number != $major_translated_number ) {
187 joy 1.1 return "This translation is too out of date";
188 thuriaux 1.65 } elsif ( $last_number - $last_translated_number < 0 ) {
189     return "Wrong translation version";
190 joy 1.1 } elsif ( $last_number - $last_translated_number >= $max_versions ) {
191     return "This translation is too out of date";
192     } elsif ( $last_number - $last_translated_number >= $min_versions ) {
193     return "The original is newer than this translation";
194     }
195 thuriaux 1.65 } elsif ( !$version && $translation) {
196 djpig 1.55 return "The original no longer exists";
197 joy 1.1 }
198     return "";
199     }
200    
201 joy 1.7 print "Collecting data in: " if ($config{'verbose'});
202 joy 1.14 if ($opt_l) {
203 barbier 1.24 getwmlfiles ($opt_l);
204 joy 1.14 getwmlfiles ('english');
205     } else {
206     foreach $lang (keys %langs) {
207 joy 1.7 getwmlfiles ($lang);
208 joy 1.14 }
209 joy 1.1 }
210     print "\n" if ($config{'verbose'});
211    
212 barbier 1.40 my @search_in;
213     if ($opt_l) {
214     @search_in = ( 'english', $opt_l );
215     } else {
216     @search_in = sort keys %langs;
217     }
218    
219 french 1.43 # Compute stats about gettext files
220 joy 1.45 print "Computing statistics in gettext files... " if ($config{'verbose'});
221 djpig 1.55 my ( %po_translated, %po_fuzzy, %po_untranslated, %po_total );
222     my ( %percent_po_t, %percent_po_u, %percent_po_f );
223 barbier 1.40 foreach $lang (@search_in) {
224     next if $lang eq 'english';
225 french 1.43 $po_translated{"total"}{$lang} = $po_fuzzy{"total"}{$lang} = $po_untranslated{"total"}{$lang} = 0;
226 jseidel 1.87 $percent_po_t{'total'}{$lang} = 0;
227     $percent_po_f{'total'}{$lang} = 0;
228     $percent_po_u{'total'}{$lang} = 100;
229     if (! -d "$opt_w/$lang/po") {
230     print "$0: can't find $opt_w/$lang/po! Skipping ...\n";
231     next;
232     }
233 french 1.43 my @status = qx,LC_ALL=C make -C $opt_w/$lang/po stats 2>&1 1>/dev/null,;
234 barbier 1.40 foreach $line (@status) {
235     chomp $line;
236     ($domain = $line) =~ s/\..*//;
237     $po_translated{$domain}{$lang} = ($line =~ /(\d+) translated/ ? $1 : "0");
238     $po_fuzzy{$domain}{$lang} = ($line =~ /(\d+) fuzzy/ ? $1 : "0");
239     $po_untranslated{$domain}{$lang} = ($line =~ /(\d+) untranslated/ ? $1 : "0");
240 french 1.43
241 barbier 1.40 $po_total{$domain} = $po_translated{$domain}{$lang} + $po_fuzzy{$domain}{$lang} + $po_untranslated{$domain}{$lang};
242 toddy 1.74
243 french 1.43 $po_translated{"total"}{$lang} += $po_translated{$domain}{$lang};
244     $po_fuzzy{"total"}{$lang} += $po_fuzzy{$domain}{$lang};
245     $po_untranslated{"total"}{$lang} += $po_untranslated{$domain}{$lang};
246 toddy 1.74
247 barbier 1.42 if ($po_total{$domain} > 0) {
248     $percent_po_t{$domain}{$lang} = int ($po_translated{$domain}{$lang}/$po_total{$domain} * 100 + .5);
249     $percent_po_f{$domain}{$lang} = int ($po_fuzzy{$domain}{$lang}/$po_total{$domain} * 100 + .5);
250     $percent_po_u{$domain}{$lang} = int ($po_untranslated{$domain}{$lang}/$po_total{$domain} * 100 + .5);
251     } else {
252     $percent_po_t{$domain}{$lang} = 0;
253     $percent_po_f{$domain}{$lang} = 0;
254 jseidel 1.87 $percent_po_u{$domain}{$lang} = 0; # or 100 if po/ doesn't exist
255 barbier 1.42 }
256 barbier 1.40 }
257 french 1.43 $po_total{"total"} = $po_translated{"total"}{$lang} + $po_fuzzy{"total"}{$lang} + $po_untranslated{"total"}{$lang};
258 toddy 1.74
259 french 1.43 if ($po_total{'total'} > 0) {
260     $percent_po_t{'total'}{$lang} = int ($po_translated{'total'}{$lang}/$po_total{'total'} * 100 + .5);
261     $percent_po_f{'total'}{$lang} = int ($po_fuzzy{'total'}{$lang}/$po_total{'total'} * 100 + .5);
262     $percent_po_u{'total'}{$lang} = int ($po_untranslated{'total'}{$lang}/$po_total{'total'} * 100 + .5);
263     }
264 barbier 1.40 }
265 french 1.43 print "done.\n" if ($config{'verbose'});
266 barbier 1.40
267 joy 1.1 # =============== Create HTML files ===============
268 joy 1.14 mkdir ($config{'htmldir'}, 02775) if (! -d $config{'htmldir'});
269 joy 1.1
270 kraai 1.27 my @filenames = sort keys %files;
271     my $nfiles = scalar @filenames;
272 bertol 1.70 $nsize += $sizes{$_} foreach (@filenames);
273 joy 1.1
274 joy 1.85 my $firstdifftype;
275     my $seconddifftype;
276     if ($config{'difftype'} eq 'u') {
277     $firstdifftype = 'u';
278     $seconddifftype = 'h';
279     } else {
280     $firstdifftype = 'h';
281     $seconddifftype = 'u';
282     }
283    
284 joy 1.7 print "Creating files: " if ($config{'verbose'});
285 joy 1.14 foreach $lang (@search_in) {
286 barbier 1.59 my @processed_langs = ($langs{$lang});
287     @processed_langs = ("zh-cn", "zh-tw") if $langs{$lang} eq "zh";
288     foreach $l (@processed_langs) {
289 barbier 1.60 print "$l.html " if ($config{'verbose'});
290 joy 1.8
291 fjp 1.82 $t_body = $u_body = $ui_body = $un_body = $uu_body = $o_body = "";
292 thuriaux 1.64 $translated{$lang} = $outdated{$lang} = $untranslated{$lang} = 0;
293 joy 1.4
294 barbier 1.60 # get stats about files
295     foreach $file (@filenames) {
296     next if ($file eq "");
297     # Translated pages
298     if (index ($wmlfiles{$lang}, " $file ") >= 0) {
299     $translated{$lang}++;
300 bertol 1.70 $translated_s{$lang} += $sizes{$file};
301 barbier 1.60 $orig = $original{"$lang/$file"} || "english";
302     # Outdated translations
303     $msg = check_translation ($transversion{"$lang/$file"}, $version{"$orig/$file"}, "$lang/$file");
304     if (length ($msg)) {
305     $o_body .= "<tr>";
306 toddy 1.74 if (($file !~ /\.wml$/)
307 barbier 1.60 || ($file eq "devel/wnpp/wnpp.wml")) {
308     $o_body .= sprintf "<td>%s</td>", $file;
309     } else {
310     (my $base = $file) =~ s/\.wml$//;
311 witch 1.72 $o_body .= sprintf "<td><a href=\"$opt_b/%s.%s.html\">%s</a></td>", $base, $l, $base;
312 barbier 1.60 }
313     $o_body .= sprintf "<td>%s</td>", $transversion{"$lang/$file"};
314     $o_body .= sprintf "<td>%s</td>", $version{"$orig/$file"};
315     $o_body .= sprintf "<td>%s</td>", $msg;
316 thuriaux 1.65 if ($msg eq "Wrong translation version" || $msg eq "The original no longer exists") {
317     $o_body .= "<td></td><td></td>";
318     } else {
319 joy 1.85 $o_body .= sprintf "<td><a href=\"http://cvs.debian.org/webwml/$orig/%s.diff\?r1=%s\&amp;r2=%s\&amp;cvsroot=webwml\&amp;diff_format=%s\">%s\&nbsp;->\&nbsp;%s</a></td>",
320     $file, $transversion{"$lang/$file"}, $version{"$orig/$file"}, $firstdifftype, $transversion{"$lang/$file"}, $version{"$orig/$file"};
321     $o_body .= sprintf "<td><a href=\"http://cvs.debian.org/webwml/$orig/%s.diff\?r1=%s\&amp;r2=%s\&amp;cvsroot=webwml\&amp;diff_format=%s\">%s\&nbsp;->\&nbsp;%s</a></td>",
322     $file, $transversion{"$lang/$file"}, $version{"$orig/$file"}, $seconddifftype, $transversion{"$lang/$file"}, $version{"$orig/$file"};
323 thuriaux 1.65 $o_body .= sprintf "<td><a href=\"http://cvs.debian.org/webwml/$orig/%s?cvsroot=webwml#rev%s\">[L]</a></td>", $file, $version{"$orig/$file"};
324     }
325 spaillar 1.86 $o_body .= sprintf "<td><a href=\"http://cvs.debian.org/*checkout*/webwml/%s/%s?content-type=text/plain\">[F]</a>&nbsp;<a href=\"http://cvs.debian.org/webwml/%s/%s?cvsroot=webwml\">[L]</a></td>", $lang, $file, $lang, $file;
326 barbier 1.60 $o_body .= sprintf "<td align=center>%s</td>", $maintainer{"$lang/$file"} || "";
327     $o_body .= "</tr>\n";
328     $outdated{$lang}++;
329 bertol 1.70 $outdated_s{$lang} += $sizes{$file};
330 barbier 1.60 # Up-to-date translations
331     } else {
332 toddy 1.74 if (($file !~ /\.wml$/)
333 barbier 1.60 || ($file eq "devel/wnpp/wnpp.wml")) {
334 witch 1.72 $t_body .= sprintf "<li>%s</li>\n", $file;
335 barbier 1.60 } else {
336     (my $base = $file) =~ s/\.wml$//;
337 witch 1.72 $t_body .= sprintf "<li><a href=\"$opt_b/%s.%s.html\">%s</a></li>\n", $base, $l, $base;
338 barbier 1.60 }
339     }
340     }
341     # Untranslated pages
342     else {
343 fjp 1.79 my $u_tmp;
344 barbier 1.60 if (($file !~ /\.wml$/)
345     || ($file eq "devel/wnpp/wnpp.wml")) {
346 fjp 1.79 $u_tmp = sprintf "<tr><td>%s</td><td>&nbsp;</td></tr>\n", $file;
347 barbier 1.60 } else {
348     (my $base = $file) =~ s/\.wml$//;
349 fjp 1.88 $u_tmp = sprintf "<tr><td><a href=\"$opt_b/%s\">%s&nbsp;&nbsp;(%s)</a></td><td align=\"right\">%d</td><td>(%.2f&nbsp;&permil;)</td></tr>\n", $base, $base, $version{"$orig/$file"}, $sizes{$file}, $sizes{$file}/$nsize * 1000;
350 barbier 1.60 }
351 fjp 1.82 if (($file =~ /international\//) &&
352 fjp 1.83 (($file !~ /international\/index.wml$/) ||
353     ($file !~ /international\/l10n\//))) {
354 fjp 1.82 $ui_body .=$u_tmp;
355     } elsif ((($file =~ /(News|events|security|vote)\/[0-9]{4}\//) &&
356     ($file !~ /index.wml$/)) ||
357     ($file =~ /(News\/weekly\/[0-9]{4}\/|security\/undated)/)) {
358 fjp 1.79 $un_body .= $u_tmp;
359     } elsif (($file =~ /(consultants|users\/(com|edu|gov|org))\//) &&
360     ($file !~ /index.wml$/)) {
361     $uu_body .=$u_tmp;
362     } else {
363     $u_body .= $u_tmp;
364     }
365 barbier 1.60 $untranslated{$lang}++;
366 bertol 1.70 $untranslated_s{$lang} += $sizes{$file};
367 barbier 1.60 }
368     }
369 toddy 1.74
370    
371 barbier 1.60 # this is where we discard the files that the translation directory contains
372     # but which don't exist in the English directory
373     # print "extra files: ".$wml{$lang}-$translated{$lang}."\n";
374     $wml{$lang} = $translated{$lang};
375 bertol 1.70 $wml_s{$lang} = $translated_s{$lang};
376 barbier 1.60 $translated{$lang} = $translated{$lang} - $outdated{$lang};
377 bertol 1.70 $translated_s{$lang} = $translated_s{$lang} - $outdated_s{$lang};
378 toddy 1.74
379 barbier 1.60 if ($nfiles > 0) {
380 toddy 1.78 $percent_a{$lang} = $wml{$lang}/$nfiles * 100;
381 barbier 1.60 } else {
382     $percent_a{$lang} = 0;
383 toddy 1.78 }
384     if ($nsize > 0) {
385     $percent_as{$lang} = $wml_s{$lang}/$nsize * 100;
386     } else {
387 bertol 1.70 $percent_as{$lang} = 0;
388 barbier 1.60 }
389     if ($wml{$lang} > 0) {
390 toddy 1.78 $percent_t{$lang} = $translated{$lang}/$wml{$lang} * 100;
391 barbier 1.60 } else {
392     $percent_t{$lang} = 0;
393 toddy 1.78 }
394     if ($wml_s{$lang} > 0) {
395     $percent_ts{$lang} = $translated_s{$lang}/$wml_s{$lang} * 100;
396     } else {
397 bertol 1.70 $percent_ts{$lang} = 0;
398 barbier 1.60 }
399     $percent_o{$lang} = 100 - $percent_t{$lang};
400 bertol 1.70 $percent_os{$lang} = 100 - $percent_ts{$lang};
401 barbier 1.60 $percent_u{$lang} = 100 - $percent_a{$lang};
402 bertol 1.70 $percent_us{$lang} = 100 - $percent_as{$lang};
403 toddy 1.74
404 barbier 1.60 if (open (HTML, ">$config{'htmldir'}/$l.html")) {
405 witch 1.72 printf HTML "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n";
406     # printf HTML "<html><head><title>%s: %s</title></head><body bgcolor=\"#ffffff\">\n", $config{'title'}, ucfirst $lang;
407     printf HTML "<html>\n<head>\n";
408     printf HTML " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
409     printf HTML " <title>%s: %s</title>\n", $config{'title'}, ucfirst $lang;
410     print HTML " <link href=\"../../../debian.css\" rel=\"stylesheet\" type=\"text/css\">";
411     print HTML "</head>\n<body>\n";
412 barbier 1.60 $color = get_color ($percent_a{$lang});
413 toddy 1.74
414 witch 1.72 printf HTML "<h1 style=\"background-color: %s\; margin: 0\;\"><a name=\"top\"></a>", $color;
415     printf HTML "%s: %s</h1>\n", $config{'title'}, ucfirst $lang;
416 witch 1.73 printf HTML "<table summary=\"Translation Summary for $lang\" style=\"background-color: %s\; width: 100%\; font-weight: bold\; margin: 0\; text-align: center\;\">\n", $color;
417 witch 1.72 print HTML "<colgroup span=\"4\" width=\"25%\"></colgroup>\n";
418     # printf HTML "<tr><td colspan=4><h1 align=\"center\">%s: %s</h1></td></tr>", $config{'title'}, ucfirst $lang;
419 toddy 1.74
420 witch 1.72 print HTML "<tr><th>Translated</th><th>Up-to-date</th><th>Outdated</th><th>Not translated</th></tr>\n<tr>";
421 fjp 1.79 printf HTML "<td>%d files (%.1f%%)</td>", $wml{$lang}, $percent_a{$lang};
422     printf HTML "<td>%d files (%.1f%%)</td>", $translated{$lang}, $percent_t{$lang};
423     printf HTML "<td>%d files (%.1f%%)</td>", $outdated{$lang}, $percent_o{$lang};
424 toddy 1.78 printf HTML "<td>%d files (%.1f%%)</td>", $untranslated{$lang}, $percent_u{$lang};
425 barbier 1.60 print HTML "</tr>\n";
426 bertol 1.70 print HTML "<tr>\n";
427 fjp 1.79 printf HTML "<td>%d bytes (%.1f%%)</td>", $wml_s{$lang}, $percent_as{$lang};
428     printf HTML "<td>%d bytes (%.1f%%)</td>", $translated_s{$lang}, $percent_ts{$lang};
429     printf HTML "<td>%d bytes (%.1f%%)</td>", $outdated_s{$lang}, $percent_os{$lang};
430 witch 1.72 printf HTML "<td>%d bytes (%.1f%%)</td>", $nsize-$wml_s{$lang}, $percent_us{$lang};
431 bertol 1.70 print HTML "</tr>\n";
432 barbier 1.60 print HTML "</table>\n";
433 toddy 1.74
434 barbier 1.60 # Make the table of content
435     print HTML "<h3>Table of Contents</h3>\n";
436 witch 1.72 print HTML "<ul>\n";
437 toddy 1.76 print HTML "<li><a href=\"./\">Back to index of languages</a></li>\n";
438     print HTML "<li><a href=\"../\">Working on the website</a></li>\n";
439 barbier 1.60 if ($o_body) {
440 toddy 1.76 print HTML "<li><a href=\"#outdated\">Outdated translations</a></li>\n";
441 barbier 1.60 }
442 fjp 1.82 if (($u_body) || ($ui_body) || ($un_body) || ($uu_body)) {
443 fjp 1.84 print HTML "<li>Untranslated\n";
444 fjp 1.80 print HTML "<ul>\n";
445     if ($u_body) {
446     print HTML "<li><a href=\"#untranslated\">General pages</a></li>\n";
447     }
448 fjp 1.82 if ($ui_body) {
449     print HTML "<li><a href=\"#untranslated-l10n\">International pages</a></li>\n";
450     }
451 fjp 1.80 if ($un_body) {
452     print HTML "<li><a href=\"#untranslated-news\">News items</a></li>\n";
453     }
454     if ($uu_body) {
455     print HTML "<li><a href=\"#untranslated-user\">Consultant/user pages</a></li>\n";
456     }
457 fjp 1.84 print HTML "</ul></li>\n";
458 barbier 1.60 }
459     if ($t_body) {
460 fjp 1.80 print HTML "<li><a href=\"#uptodate\">Translated pages (up-to-date)</a></li>\n";
461 barbier 1.60 }
462     if ($lang ne 'english') {
463 fjp 1.80 print HTML "<li><a href=\"#gettext\">Translation of templates (gettext files)</a></li>\n";
464 barbier 1.60 }
465 witch 1.72 print HTML "</ul>\n";
466 toddy 1.74
467 barbier 1.60 # outputs the content
468     if ($o_body) {
469 fjp 1.80 print HTML "<h3 id='outdated'>Outdated translations: <a href='#top'>(top)</a></h3>\n";
470     print HTML "<table summary=\"Outdated translations\" border=0 cellpadding=1 cellspacing=1>\n";
471 barbier 1.60 print HTML "<tr><th>File</th><th>Translated</th><th>Origin</th><th>Comment</th>";
472 joy 1.85 if ($opt_d eq "u") { print HTML "<th>Unified diff</th><th>Colored diff</th>"; }
473     elsif ($opt_d eq "h") { print HTML "<th>Colored diff</th><th>Unified diff</th>"; }
474 barbier 1.60 else { print HTML "<th>Diff</th>"; }
475     print HTML "<th>Log</th>";
476 spaillar 1.86 print HTML "<th>Translation</th>";
477 barbier 1.60 print HTML "<th>Maintainer</th>";
478     print HTML "</tr>\n";
479     print HTML $o_body;
480     print HTML "</table>\n";
481     }
482     if ($u_body) {
483 fbothamy 1.81 print HTML "<h3 id='untranslated'>General pages not translated: <a href='#top'>(top)</a></h3>\n";
484 fjp 1.80 print HTML "<table summary=\"Untranslated general pages\">\n";
485 barbier 1.60 print HTML $u_body;
486 fjp 1.80 print HTML "</table>\n";
487 barbier 1.60 }
488 fjp 1.82 if ($ui_body) {
489     print HTML "<h3 id='untranslated-l10n'>International pages not translated: <a href='#top'>(top)</a></h3>\n";
490     print HTML "<table summary=\"Untranslated international pages\">\n";
491     print HTML $ui_body;
492     print HTML "</table>\n";
493     }
494 fjp 1.79 if ($un_body) {
495 fjp 1.80 print HTML "<h3 id='untranslated-news'>News items not translated: <a href='#top'>(top)</a></h3>\n";
496     print HTML "<table summary=\"Untranslated news items\">\n";
497 fjp 1.79 print HTML $un_body;
498 fjp 1.80 print HTML "</table>\n";
499 fjp 1.79 }
500     if ($uu_body) {
501 fjp 1.80 print HTML "<h3 id='untranslated-user'>Consultant/user pages not translated: <a href='#top'>(top)</a></h3>\n";
502     print HTML "<table summary=\"Untranslated consultant/user pages\">\n";
503 fjp 1.79 print HTML $uu_body;
504 fjp 1.80 print HTML "</table>\n";
505 fjp 1.79 }
506 barbier 1.60 if ($t_body) {
507 fjp 1.80 print HTML "<h3 id='uptodate'>Translated pages (up-to-date): <a href='#top'>(top)</a></h3>\n";
508     print HTML "<ul class=\"discless\">\n";
509 barbier 1.60 print HTML $t_body;
510 fjp 1.80 print HTML "</ul>\n";
511 barbier 1.60 }
512     # outputs the gettext stats
513     if ($lang ne 'english') {
514 fjp 1.80 print HTML "<h3 id='gettext'>Translation of templates (gettext files): <a href='#top'>(top)</a></h3>\n";
515     # print HTML $border_head;
516 fjp 1.79 print HTML "<table summary=\"Gettext statistics\" width=\"100%\">\n";
517 barbier 1.60 print HTML "<tr><th>File</th><th>Up to date</th><th>Fuzzy</th><th>Untranslated</th><th>Total</th></tr>\n";
518     foreach my $domain (sort keys %po_total) {
519     next if $domain eq 'total';
520     print HTML "<tr>";
521 toddy 1.74
522 barbier 1.60 $color_t = get_color ($percent_po_t{$domain}{$lang});
523     $color_f = get_color (100 - $percent_po_f{$domain}{$lang});
524     $color_u = get_color (100 - $percent_po_u{$domain}{$lang});
525 toddy 1.74
526 barbier 1.60 print HTML "<td>$domain.$langs{$lang}.po</td>";
527 witch 1.72 printf HTML "<td style=\"background-color: %s\" align=right>%d (%s%%)</td>", $color_t, $po_translated{$domain}{$lang}, $percent_po_t{$domain}{$lang};
528     printf HTML "<td style=\"background-color: %s\" align=right>%d (%s%%)</td>", $color_f, $po_fuzzy{$domain}{$lang}, $percent_po_f{$domain}{$lang};
529     printf HTML "<td style=\"background-color: %s\" align=right>%d (%s%%)</td>", $color_u, $po_untranslated{$domain}{$lang}, $percent_po_u{$domain}{$lang};
530 barbier 1.60 printf HTML "<td align=right>%d</td>", $po_total{$domain};
531     print HTML "</tr>\n";
532     }
533     print HTML "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><th>Total:</th>";
534     $color_t = get_color ($percent_po_t{'total'}{$lang});
535     $color_f = get_color (100 - $percent_po_f{'total'}{$lang});
536     $color_u = get_color (100 - $percent_po_u{'total'}{$lang});
537 witch 1.72 printf HTML "<td style=\"background-color: %s\" align=right>%d (%d%%)</td>", $color_t, $po_translated{'total'}{$lang}, $percent_po_t{'total'}{$lang};
538     printf HTML "<td style=\"background-color: %s\" align=right>%d (%d%%)</td>", $color_f, $po_fuzzy{'total'}{$lang}, $percent_po_f{'total'}{$lang};
539     printf HTML "<td style=\"background-color: %s\" align=right>%d (%d%%)</td>", $color_u, $po_untranslated{'total'}{$lang}, $percent_po_u{'total'}{$lang};
540 barbier 1.60 printf HTML "<td align=right>%d</td>", $po_total{'total'};
541     print HTML "</tr>\n";
542 fjp 1.84 print HTML "</table>\n";
543 barbier 1.60 }
544 toddy 1.74
545 barbier 1.60 # outputs footer
546     print HTML "<hr><address>Compiled at $date</address>\n";
547     print HTML "</body></html>";
548     close (HTML);
549     }
550 joy 1.1 }
551     }
552 joy 1.7 print "\n" if ($config{'verbose'});
553 joy 1.1
554     # =============== Creating index.html ===============
555 joy 1.7 print "Creating index.html... " if ($config{'verbose'});
556 joy 1.1
557 witch 1.72 open (HTMLI, ">$config{'htmldir'}/index.html")
558 joy 1.1 || die "Can't open $config{'htmldir'}/index.html";
559    
560 witch 1.72 # printf HTMLI "<html>\n<head><title>%s</title></head>\n<body bgcolor=\"#ffffff\">\n", $config{'title'};
561     # printf HTMLI "<h1 align=\"center\">%s</h1>\n", $config{'title'};
562     printf HTMLI "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n";
563     printf HTMLI " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
564     printf HTMLI " <title>%s</title>\n", $config{'title'};
565     print HTMLI " <link href=\"../../../debian.css\" rel=\"stylesheet\" type=\"text/css\">";
566     printf HTMLI "</head>\n<body>\n";
567     printf HTMLI "<h1>%s</h1>\n", $config{'title'};
568     print HTMLI "<h2>Translated web pages</h2>\n";
569     printf HTMLI "<p>There are %d pages to translate.</p>\n",($wml{'english'}+$untranslated{'english'});
570    
571     # print HTMLI $border_head;
572 witch 1.73 print HTMLI "<table summary=\"Translation Statistics by Page Count\" class=\"stattrans\">\n";
573 witch 1.72 print HTMLI "<colgroup width=\"20%\">\n";
574     print HTMLI "<col>\n";
575     print HTMLI "</colgroup>";
576     print HTMLI "<colgroup width=\"10%\">\n";
577     print HTMLI "<col width=\"10%\">\n";
578     print HTMLI "<col width=\"10%\">\n";
579     print HTMLI "<col width=\"10%\">\n";
580     print HTMLI "<col width=\"10%\">\n";
581     print HTMLI "<col width=\"10%\">\n";
582     print HTMLI "<col width=\"10%\">\n";
583     print HTMLI "<col width=\"10%\">\n";
584     print HTMLI "<col width=\"10%\">\n";
585     print HTMLI "</colgroup>";
586     print HTMLI "<thead>";
587     print HTMLI "<tr><th>Language</th><th colspan=\"2\">Translations</th><th colspan=\"2\">Up to date</th><th colspan=\"2\">Outdated</th><th colspan=\"2\">Not translated</th></tr>\n";
588     print HTMLI "</thead>";
589     print HTMLI "<tbody>";
590 joy 1.14 foreach $lang (@search_in) {
591 barbier 1.61 my @processed_langs = ($langs{$lang});
592     @processed_langs = ("zh-cn", "zh-tw") if $langs{$lang} eq "zh";
593     foreach $l (@processed_langs) {
594 barbier 1.62 $color_a = get_color ($percent_a{$lang});
595     $color_t = get_color ($percent_t{$lang});
596     $color_o = get_color (100 - $percent_o{$lang});
597     $color_u = get_color (100 - $percent_u{$lang});
598    
599 witch 1.72 print HTMLI "<tr>";
600     printf HTMLI "<th><a href=\"%s.html\">%s</a> (%s)</th>", $l, ucfirst $lang, $l;
601 toddy 1.78 printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_a, $wml{$lang}, $percent_a{$lang};
602     printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_t, $translated{$lang}, $percent_t{$lang};
603     printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_o, $outdated{$lang}, $percent_o{$lang};
604     printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_u, $untranslated{$lang}, $percent_u{$lang};
605 witch 1.72 print HTMLI "</tr>\n";
606 barbier 1.61 }
607 joy 1.1 }
608 witch 1.72 print HTMLI "</tbody>";
609     print HTMLI "</table>\n";
610     # print HTMLI $border_foot;
611    
612     print HTMLI "<h2>Translated web pages (by size)</h2>\n";
613     printf HTMLI "<p>There are %d bytes to translate.</p>\n",($wml_s{'english'}+$untranslated_s{'english'});
614    
615     # print HTMLI $border_head;
616 witch 1.73 print HTMLI "<table summary=\"Translation Statistics by Page Size\" class=\"stattrans\">\n";
617 witch 1.72 # print HTMLI "<table width=\"100%\" border=0 bgcolor=\"#cdc9c9\">\n";
618     print HTMLI "<colgroup span=\"1\">\n";
619     print HTMLI "<col width=\"20%\">\n";
620     print HTMLI "</colgroup>";
621     print HTMLI "<colgroup span=\"8\">\n";
622     print HTMLI "<col width=\"13%\">\n";
623     print HTMLI "<col width=\"7%\">\n";
624     print HTMLI "<col width=\"13%\">\n";
625     print HTMLI "<col width=\"7%\">\n";
626     print HTMLI "<col width=\"13%\">\n";
627     print HTMLI "<col width=\"7%\">\n";
628     print HTMLI "<col width=\"13%\">\n";
629     print HTMLI "<col width=\"7%\">\n";
630     print HTMLI "</colgroup>";
631     print HTMLI "<thead>";
632     print HTMLI "<tr><th>Language</th><th colspan=\"2\">Translations</th><th colspan=\"2\">Up to date</th><th colspan=\"2\">Outdated</th><th colspan=\"2\">Not translated</th></tr>\n";
633     print HTMLI "</thead>";
634     print HTMLI "<tbody>";
635 bertol 1.70
636     foreach $lang (@search_in) {
637     my @processed_langs = ($langs{$lang});
638     @processed_langs = ("zh-cn", "zh-tw") if $langs{$lang} eq "zh";
639     foreach $l (@processed_langs) {
640     $color_a = get_color ($percent_a{$lang});
641     $color_t = get_color ($percent_t{$lang});
642     $color_o = get_color (100 - $percent_o{$lang});
643     $color_u = get_color (100 - $percent_u{$lang});
644    
645 witch 1.72 print HTMLI "<tr>";
646     printf HTMLI "<th><a href=\"%s.html\">%s</a> (%s)</th>", $l, ucfirst $lang, $l;
647 toddy 1.77 printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_a, $wml_s{$lang}, $percent_as{$lang};
648     printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_t, $translated_s{$lang}, $percent_ts{$lang};
649     printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_o, $outdated_s{$lang}, $percent_os{$lang};
650     printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_u, $wml_s{"english"}+$untranslated_s{'english'}-$wml_s{$lang}, $percent_us{$lang};
651 witch 1.72 print HTMLI "</tr>\n";
652 bertol 1.70 }
653     }
654 witch 1.72 print HTMLI "</tbody>";
655     print HTMLI "</table>\n";
656     # print HTMLI $border_foot;
657    
658     print HTMLI "<h2>Translated templates (gettext files)</h2>\n";
659     printf HTMLI "<p>There are %d strings to translate.</p>\n",$po_total{'total'};
660     # print HTMLI $border_head;
661 witch 1.73 print HTMLI "<table summary=\"Gettext Translation Statistiks\"class=\"stattrans\">\n";
662 witch 1.72 # print HTMLI "<table width=\"100%\" border=0 bgcolor=\"#cdc9c9\">\n";
663     print HTMLI "<colgroup span=\"1\"width=\"28%\">\n";
664     print HTMLI "</colgroup>";
665     print HTMLI "<colgroup span=\"6\" width=\"12%\">\n";
666     print HTMLI "<col width=\"12%\">\n";
667     print HTMLI "<col width=\"12%\">\n";
668     print HTMLI "<col width=\"12%\">\n";
669     print HTMLI "<col width=\"12%\">\n";
670     print HTMLI "<col width=\"12%\">\n";
671     print HTMLI "<col width=\"12%\">\n";
672     print HTMLI "</colgroup>";
673     print HTMLI "<thead>";
674     print HTMLI "<tr><th>Language</th><th colspan=\"2\">Up to date</th><th colspan=\"2\">Fuzzy</th><th colspan=\"2\">Not translated</th></tr>\n";
675     print HTMLI "</thead>";
676     print HTMLI "<tbody>";
677 barbier 1.40 foreach $lang (@search_in) {
678     next if $lang eq 'english';
679 barbier 1.61 my @processed_langs = ($langs{$lang});
680     @processed_langs = ("zh-cn", "zh-tw") if $langs{$lang} eq "zh";
681     foreach $l (@processed_langs) {
682 witch 1.72 print HTMLI "<tr>";
683     printf HTMLI "<th><a href=\"%s.html#gettext\">%s</a> (%s)</th>", $l, ucfirst $lang, $l;
684 barbier 1.62 $color_t = get_color ($percent_po_t{'total'}{$lang});
685     $color_f = get_color (100 - $percent_po_f{'total'}{$lang});
686     $color_u = get_color (100 - $percent_po_u{'total'}{$lang});
687 toddy 1.77 printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%d%%)</td>", $color_t, $po_translated{'total'}{$lang}, $percent_po_t{'total'}{$lang};
688     printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%d%%)</td>", $color_f, $po_fuzzy{'total'}{$lang}, $percent_po_f{'total'}{$lang};
689     printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%d%%)</td>", $color_u, $po_untranslated{'total'}{$lang}, $percent_po_u{'total'}{$lang};
690 witch 1.72 print HTMLI "</tr>\n";
691 barbier 1.61 }
692 french 1.43 }
693 barbier 1.40
694 witch 1.72 print HTMLI "</tbody>";
695     print HTMLI "</table>\n";
696     # print HTMLI $border_foot;
697    
698     print HTMLI "<p><hr>\n";
699 fjp 1.84 print HTMLI "<p><address>Created with <a href=\"http://cvs.debian.org/webwml/stattrans.pl?cvsroot=webwml\">webwml-stattrans</a> on $date</address>\n";
700 witch 1.72 print HTMLI "</body></html>\n";
701     close (HTMLI);
702 joy 1.1
703 joy 1.7 print "done.\n" if ($config{'verbose'});
704 joy 1.1
705     # Note:
706     # Translated pages on ll.html may be higher than in index.html.
707     # This is due to the fact that some english pages were removed.
708    
709     # printf "%s\n", join ("\n", keys %version);
710     # printf "%s - %s\n", $version{'german/devel/index'}, $version{'english/devel/index'};

  ViewVC Help
Powered by ViewVC 1.1.5