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

Contents of /webwml/stattrans.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.58 - (hide annotations) (download)
Fri Jan 23 18:26:24 2004 UTC (9 years, 3 months ago) by barbier
Branch: MAIN
Changes since 1.57: +10 -2 lines
File MIME type: text/plain
Avoid divisions by zero.
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 joy 1.6 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 joy 1.34 getopts('h:w:p:t:vd:l:') || die;
40 barbier 1.24 # Replace filename globbing by Perl regexps
41 djpig 1.54 $opt_p =~ s/\./\\./g;
42 barbier 1.24 $opt_p =~ s/\?/./g;
43     $opt_p =~ s/\*/.*/g;
44     $opt_p =~ s/$/\$/g;
45 joy 1.1 %config = (
46 joy 1.6 'htmldir' => $opt_h,
47     'wmldir' => $opt_w,
48     'wmlpat' => $opt_p,
49     'title' => $opt_t,
50     'verbose' => $opt_v,
51 joy 1.36 'difftype'=> $opt_d,
52 joy 1.1 );
53    
54 barbier 1.24 my $l = Webwml::Langs->new($opt_w);
55     my %langs = $l->name_iso();
56    
57     my $transignore = Webwml::TransIgnore->new($opt_w);
58    
59     my $cvs = Local::Cvsinfo->new();
60     $cvs->options(
61     recursive => 1,
62     matchfile => [ $config{'wmlpat'} ],
63     skipdir => [ "template" ],
64     );
65     $cvs->readinfo("$config{'wmldir'}/english");
66     foreach (@{$transignore->global()}) {
67     $cvs->removefile("$config{'wmldir'}/english/$_");
68     }
69    
70     my $altcvs = Local::Cvsinfo->new();
71     $altcvs->options(
72     recursive => 1,
73     matchfile => [ $config{'wmlpat'} ],
74     skipdir => [ "template" ],
75     );
76    
77 joy 1.1 $max_versions = 5;
78     $min_versions = 1;
79    
80 barbier 1.41 $border_head = "<table width=\"95%\" align=\"center\" border=0 cellpadding=0 cellspacing=0><tr bgcolor=\"#000000\"><td>"
81     ."<table width=\"100%\" border=0 cellpadding=0 cellspacing=1><tr bgcolor=\"#ffffff\"><td>";
82 joy 1.1 $border_foot = "</td></tr></table></td></tr></table>";
83    
84    
85     $date = strftime "%a %b %e %H:%M:%S %Y %z", localtime;
86    
87 barbier 1.24 my %original;
88 barbier 1.25 my %transversion;
89     my %version;
90 kraai 1.27 my %files;
91 joy 1.1
92     # Count wml files in given directory
93     #
94     sub getwmlfiles
95     {
96     my $lang = shift;
97 joy 1.14 my $dir = "$config{'wmldir'}/$lang";
98 joy 1.1 my $cutfrom = length ($config{'wmldir'})+length($lang)+2;
99     my $count = 0;
100     my $is_english = ($lang eq "english")?1:0;
101 djpig 1.55 my ( $file, $v );
102 barbier 1.24 my @listfiles;
103 joy 1.1
104 joy 1.7 print "$lang " if ($config{verbose});
105 joy 1.14 die "$0: can't find $dir!\n" if (! -d "$dir");
106 barbier 1.24 if ($is_english) {
107     @listfiles = @{$cvs->files()};
108     } else {
109     $altcvs->reset();
110     $altcvs->readinfo($dir);
111     @listfiles = @{$altcvs->files()};
112     }
113     foreach my $f (@listfiles) {
114     $file = substr ($f, $cutfrom);
115     next if $transignore->is_global($file);
116 kraai 1.27 $files{$file} = 1;
117 joy 1.7 $wmlfiles{$lang} .= " " . $file;
118 djpig 1.57 my $transcheck = Webwml::TransCheck->new("$dir/$file");
119 barbier 1.25 if ($transcheck->revision()) {
120     $transversion{"$lang/$file"} = $transcheck->revision();
121     $original{"$lang/$file"} ||= $transcheck->original();
122     }
123 joy 1.1 if ($is_english) {
124 barbier 1.25 $version{"$lang/$file"} = $cvs->revision($f);
125     } else {
126     $version{"$lang/$file"} = $altcvs->revision($f);
127     if (!$transcheck->revision()) {
128     $original{"english/$file"} = $lang;
129 kraai 1.28 $transversion{"english/$file"} ||= "1.1";
130 barbier 1.24 }
131 joy 1.1 }
132 french 1.50 if ($transcheck->maintainer()) {
133     $maintainer{"$lang/$file"} = $transcheck->maintainer();
134     }
135 joy 1.1 $count++;
136     }
137 joy 1.7 $wmlfiles{$lang} .= " ";
138     $wml{$lang} = $count;
139 barbier 1.25 }
140 joy 1.1
141     sub get_color
142     {
143     my $percent = shift;
144    
145 kraai 1.17 if ($percent < 50) {
146     return sprintf ("#FF%02x00", (255/50) * $percent);
147 joy 1.1 } else {
148 kraai 1.17 return sprintf ("#%02xFF00", (255/50) * (100 - $percent));
149 joy 1.1 }
150     }
151    
152     sub check_translation
153     {
154     my ($translation, $version, $file) = @_;
155 djpig 1.55 my ( @version_numbers, $major_number, $last_number );
156     my ( @translation_numbers, $major_translated_number, $last_translated_number );
157 joy 1.1
158 djpig 1.55 if ( $version && $translation ) {
159 joy 1.1 @version_numbers = split /\./,$version;
160 djpig 1.55 $major_number = $version_numbers[0];
161 joy 1.1 $last_number = pop @version_numbers;
162     die "Invalid CVS revision for $file: $version\n"
163     unless ($major_number =~ /\d+/ && $last_number =~ /\d+/);
164    
165     @translation_numbers = split /\./,$translation;
166 djpig 1.55 $major_translated_number = $translation_numbers[0];
167 joy 1.1 $last_translated_number = pop @translation_numbers;
168     die "Invalid translation revision for $file: $translation\n"
169     unless ($major_translated_number =~ /\d+/ && $last_translated_number =~ /\d+/);
170    
171     # Here we compare the original version with the translated one and print
172     # a note for the user if their first or last numbers are too far apart
173     # From translation-check.wml
174    
175 djpig 1.55 if ( $major_number != $major_translated_number ) {
176 joy 1.1 return "This translation is too out of date";
177     } elsif ( $last_number - $last_translated_number >= $max_versions ) {
178     return "This translation is too out of date";
179     } elsif ( $last_number - $last_translated_number >= $min_versions ) {
180     return "The original is newer than this translation";
181     }
182 djpig 1.55 } elsif ( !$version && $transversion) {
183     return "The original no longer exists";
184 joy 1.1 }
185     return "";
186     }
187    
188 joy 1.7 print "Collecting data in: " if ($config{'verbose'});
189 joy 1.14 if ($opt_l) {
190 barbier 1.24 getwmlfiles ($opt_l);
191 joy 1.14 getwmlfiles ('english');
192     } else {
193     foreach $lang (keys %langs) {
194 joy 1.7 getwmlfiles ($lang);
195 joy 1.14 }
196 joy 1.1 }
197     print "\n" if ($config{'verbose'});
198    
199 barbier 1.40 my @search_in;
200     if ($opt_l) {
201     @search_in = ( 'english', $opt_l );
202     } else {
203     @search_in = sort keys %langs;
204     }
205    
206 french 1.43 # Compute stats about gettext files
207 joy 1.45 print "Computing statistics in gettext files... " if ($config{'verbose'});
208 djpig 1.55 my ( %po_translated, %po_fuzzy, %po_untranslated, %po_total );
209     my ( %percent_po_t, %percent_po_u, %percent_po_f );
210 barbier 1.40 foreach $lang (@search_in) {
211     next if $lang eq 'english';
212     $l = $langs{$lang};
213 french 1.43 $po_translated{"total"}{$lang} = $po_fuzzy{"total"}{$lang} = $po_untranslated{"total"}{$lang} = 0;
214     my @status = qx,LC_ALL=C make -C $opt_w/$lang/po stats 2>&1 1>/dev/null,;
215 barbier 1.40 foreach $line (@status) {
216     chomp $line;
217     ($domain = $line) =~ s/\..*//;
218     $po_translated{$domain}{$lang} = ($line =~ /(\d+) translated/ ? $1 : "0");
219     $po_fuzzy{$domain}{$lang} = ($line =~ /(\d+) fuzzy/ ? $1 : "0");
220     $po_untranslated{$domain}{$lang} = ($line =~ /(\d+) untranslated/ ? $1 : "0");
221 french 1.43
222 barbier 1.40 $po_total{$domain} = $po_translated{$domain}{$lang} + $po_fuzzy{$domain}{$lang} + $po_untranslated{$domain}{$lang};
223 french 1.43
224     $po_translated{"total"}{$lang} += $po_translated{$domain}{$lang};
225     $po_fuzzy{"total"}{$lang} += $po_fuzzy{$domain}{$lang};
226     $po_untranslated{"total"}{$lang} += $po_untranslated{$domain}{$lang};
227    
228 barbier 1.42 if ($po_total{$domain} > 0) {
229     $percent_po_t{$domain}{$lang} = int ($po_translated{$domain}{$lang}/$po_total{$domain} * 100 + .5);
230     $percent_po_f{$domain}{$lang} = int ($po_fuzzy{$domain}{$lang}/$po_total{$domain} * 100 + .5);
231     $percent_po_u{$domain}{$lang} = int ($po_untranslated{$domain}{$lang}/$po_total{$domain} * 100 + .5);
232     } else {
233     $percent_po_t{$domain}{$lang} = 0;
234     $percent_po_f{$domain}{$lang} = 0;
235     $percent_po_u{$domain}{$lang} = 0;
236     }
237 barbier 1.40 }
238 french 1.43 $po_total{"total"} = $po_translated{"total"}{$lang} + $po_fuzzy{"total"}{$lang} + $po_untranslated{"total"}{$lang};
239    
240     if ($po_total{'total'} > 0) {
241     $percent_po_t{'total'}{$lang} = int ($po_translated{'total'}{$lang}/$po_total{'total'} * 100 + .5);
242     $percent_po_f{'total'}{$lang} = int ($po_fuzzy{'total'}{$lang}/$po_total{'total'} * 100 + .5);
243     $percent_po_u{'total'}{$lang} = int ($po_untranslated{'total'}{$lang}/$po_total{'total'} * 100 + .5);
244     } else {
245     $percent_po_t{'total'}{$lang} = 0;
246     $percent_po_f{'total'}{$lang} = 0;
247     $percent_po_u{'total'}{$lang} = 0;
248     }
249 barbier 1.40 }
250 french 1.43 print "done.\n" if ($config{'verbose'});
251 barbier 1.40
252 joy 1.1 # =============== Create HTML files ===============
253 joy 1.14 mkdir ($config{'htmldir'}, 02775) if (! -d $config{'htmldir'});
254 joy 1.1
255 kraai 1.27 my @filenames = sort keys %files;
256     my $nfiles = scalar @filenames;
257 joy 1.1
258 joy 1.7 print "Creating files: " if ($config{'verbose'});
259 joy 1.14 foreach $lang (@search_in) {
260 joy 1.1 $l = $langs{$lang};
261 joy 1.7 print "$l.html " if ($config{'verbose'});
262 joy 1.8 $l = "zh-cn" if ($l eq "zh"); # kludge
263    
264     $t_body = $u_body = $o_body = "";
265 joy 1.4
266 french 1.43 # get stats about files
267 kraai 1.27 foreach $file (@filenames) {
268 barbier 1.24 next if ($file eq "");
269 joy 1.4 # Translated pages
270 joy 1.7 if (index ($wmlfiles{$lang}, " $file ") >= 0) {
271 barbier 1.24 $translated{$lang}++;
272 barbier 1.25 $orig = $original{"$lang/$file"} || "english";
273 joy 1.4 # Outdated translations
274 barbier 1.25 $msg = check_translation ($transversion{"$lang/$file"}, $version{"$orig/$file"}, "$lang/$file");
275 joy 1.4 if (length ($msg)) {
276 joy 1.12 $o_body .= "<tr>";
277 djpig 1.57 if (($file !~ /\.wml$/)
278     || ($file eq "devel/wnpp/wnpp.wml")) {
279     $o_body .= sprintf "<td>%s</td>", $file;
280 joy 1.21 } else {
281 djpig 1.57 (my $base = $file) =~ s/\.wml$//;
282     $o_body .= sprintf "<td><a href=\"/%s.%s.html\">%s</a></td>", $base, $l, $base;
283 joy 1.21 }
284 barbier 1.25 $o_body .= sprintf "<td>%s</td>", $transversion{"$lang/$file"};
285 barbier 1.24 $o_body .= sprintf "<td>%s</td>", $version{"$orig/$file"};
286 joy 1.12 $o_body .= sprintf "<td>%s</td>", $msg;
287 djpig 1.57 $o_body .= sprintf "<td>&nbsp;&nbsp;<a href=\"http://cvs.debian.org/webwml/$orig/%s.diff\?r1=%s\&amp;r2=%s\&amp;cvsroot=webwml\&amp;diff_format=%s\">%s -> %s</a></td>", $file, $transversion{"$lang/$file"}, $version{"$orig/$file"}, $config{'difftype'}, $transversion{"$lang/$file"}, $version{"$orig/$file"};
288     $o_body .= sprintf "<td><a href=\"http://cvs.debian.org/webwml/$orig/%s?cvsroot=webwml#rev%s\">[L]</a></td>", $file, $version{"$orig/$file"};
289 joy 1.53 $o_body .= sprintf "<td align=center>%s</td>", $maintainer{"$lang/$file"} || "";
290 joy 1.12 $o_body .= "</tr>\n";
291 joy 1.4 $outdated{$lang}++;
292 kraai 1.28 # Up-to-date translations
293     } else {
294 djpig 1.57 if (($file !~ /\.wml$/)
295     || ($file eq "devel/wnpp/wnpp.wml")) {
296     $t_body .= sprintf "%s<br>\n", $file;
297 kraai 1.28 } else {
298 djpig 1.57 (my $base = $file) =~ s/\.wml$//;
299     $t_body .= sprintf "<a href=\"/%s.%s.html\">%s</a><br>\n", $base, $l, $base;
300 kraai 1.28 }
301 joy 1.4 }
302     }
303     # Untranslated pages
304     else {
305 djpig 1.57 if (($file !~ /\.wml$/)
306     || ($file eq "devel/wnpp/wnpp.wml")) {
307     $u_body .= sprintf "%s<br>\n", $file;
308 joy 1.21 } else {
309 djpig 1.57 (my $base = $file) =~ s/\.wml$//;
310     $u_body .= sprintf "<a href=\"/%s\">%s</a><br>\n", $base, $base;
311 joy 1.21 }
312 joy 1.4 $untranslated{$lang}++;
313     }
314     }
315 french 1.43
316    
317 joy 1.8 # this is where we discard the files that the translation directory contains
318     # but which don't exist in the English directory
319     # print "extra files: ".$wml{$lang}-$translated{$lang}."\n";
320     $wml{$lang} = $translated{$lang};
321 joy 1.6 $translated{$lang} = $translated{$lang} - $outdated{$lang};
322    
323 barbier 1.58 if ($nfiles > 0) {
324     $percent_a{$lang} = int ($wml{$lang}/$nfiles * 100 + .5);
325     } else {
326     $percent_a{$lang} = 0;
327     }
328     if ($wml{$lang} > 0) {
329     $percent_t{$lang} = int ($translated{$lang}/$wml{$lang} * 100 + .5);
330     } else {
331     $percent_t{$lang} = 0;
332     }
333 ender 1.39 $percent_o{$lang} = 100 - $percent_t{$lang};
334 kraai 1.28 $percent_u{$lang} = 100 - $percent_a{$lang};
335 joy 1.4
336 joy 1.1 if (open (HTML, ">$config{'htmldir'}/$l.html")) {
337 barbier 1.41 printf HTML "<html><head><title>%s: %s</title></head><body bgcolor=\"#ffffff\">\n", $config{'title'}, ucfirst $lang;
338 joy 1.1
339 joy 1.7 $color = get_color ($percent_a{$lang});
340 joy 1.1
341 barbier 1.44 print HTML "<a name=\"top\"></a>\n";
342 barbier 1.41 printf HTML "<table width=\"100%%\" cellpadding=2 cellspacing=0 bgcolor=\"%s\">\n", $color;
343 joy 1.1
344 barbier 1.41 printf HTML "<tr><td colspan=4><h1 align=\"center\">%s: %s</h1></td></tr>", $config{'title'}, ucfirst $lang;
345 joy 1.1
346 joy 1.4 print HTML "<tr>\n";
347 barbier 1.41 printf HTML "<td align=\"center\" width=\"25%%\"><b>%d files (%d%%) translated</b></td>", $wml{$lang}, $percent_a{$lang};
348     printf HTML "<td align=\"center\" width=\"25%%\"><b>%d files (%d%%) up to date</b></td>", $translated{$lang}, $percent_t{$lang};
349     printf HTML "<td align=\"center\" width=\"25%%\"><b>%d files (%d%%) outdated</b></td>", $outdated{$lang}, $percent_o{$lang};
350     printf HTML "<td align=\"center\" width=\"25%%\"><b>%d files (%d%%) not translated</b></td>", $untranslated{$lang}, $percent_u{$lang};
351 joy 1.8 print HTML "</tr>\n";
352     print HTML "</table>\n";
353 joy 1.1
354 french 1.43 # Make the table of content
355     print HTML "<h3>Table of Contents</h3>\n";
356     print HTML "<p><a href=\"./\">Back to index of languages</a></p>\n";
357 alfie 1.49 print HTML "<br /><a href=\"../\">Working on the website</a>\n";
358 french 1.43 if ($o_body) {
359 alfie 1.49 print HTML "<br /><a href=\"#outdated\">Outdated translations</a>\n";
360 french 1.43 }
361     if ($u_body) {
362 alfie 1.49 print HTML "<br /><a href=\"#untranslated\">Pages not translated</a>\n";
363 french 1.43 }
364     if ($t_body) {
365 alfie 1.49 print HTML "<br /><a href=\"#uptodate\">Translations up to date</a>\n";
366 french 1.43 }
367     if ($lang ne 'english') {
368 alfie 1.49 print HTML "<br /><a href=\"#gettext\">Translations of templates (gettext files)</a>\n";
369 french 1.43 }
370 alfie 1.49 print HTML "</p>\n";
371 french 1.43
372     # outputs the content
373 joy 1.4 if ($o_body) {
374 barbier 1.46 print HTML "<h3><a name='outdated'>Outdated translations</a>: <a href='#top'>(top)</a></h3>\n";
375 joy 1.1 print HTML "<table border=0 cellpadding=1 cellspacing=1>\n";
376 alfie 1.32 print HTML "<tr><th>File</th><th>Translated</th><th>Origin</th><th>Comment</th>";
377 joy 1.12 if ($opt_d eq "u") { print HTML "<th>Unified diff</th>"; }
378     elsif ($opt_d eq "h") { print HTML "<th>Colored diff</th>"; }
379     else { print HTML "<th>Diff</th>"; }
380 djpig 1.56 print HTML "<th>Log</th>";
381 french 1.50 print HTML "<th>Maintainer</th>";
382 joy 1.12 print HTML "</tr>\n";
383 joy 1.4 print HTML $o_body;
384 joy 1.1 print HTML "</table>\n";
385     }
386 joy 1.4 if ($u_body) {
387 barbier 1.46 print HTML "<h3><a name='untranslated'>Pages not translated</a>: <a href='#top'>(top)</a></h3>\n";
388 joy 1.4 print HTML $u_body;
389 joy 1.1 }
390 joy 1.4 if ($t_body) {
391 barbier 1.46 print HTML "<h3><a name='uptodate'>Translations up to date</a>: <a href='#top'>(top)</a></h3>\n";
392 joy 1.4 print HTML $t_body;
393 joy 1.1 }
394 french 1.43 # outputs the gettext stats
395     if ($lang ne 'english') {
396 joy 1.45 print HTML "<h3><a name='gettext'>Translations of templates (gettext files)</a>: <a href='#top'>(top)</a></h3>\n";
397 french 1.43 # print HTML $border_head;
398     print HTML "<table width=\"100%\" border=0>\n";
399     print HTML "<tr><th>File</th><th>Up to date</th><th>Fuzzy</th><th>Untranslated</th><th>Total</th></tr>\n";
400     $l = $langs{$lang};
401     $l = "zh-cn" if ($l eq "zh"); # kludge
402    
403     foreach my $domain (sort keys %po_total) {
404     next if $domain eq 'total';
405     print HTML "<tr>";
406    
407     $color_t = get_color ($percent_po_t{$domain}{$lang});
408     $color_f = get_color (100 - $percent_po_f{$domain}{$lang});
409     $color_u = get_color (100 - $percent_po_u{$domain}{$lang});
410    
411     print HTML "<td>$domain.$langs{$lang}.po</td>";
412     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_t, $po_translated{$domain}{$lang}, $percent_po_t{$domain}{$lang};
413     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_f, $po_fuzzy{$domain}{$lang}, $percent_po_f{$domain}{$lang};
414     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_u, $po_untranslated{$domain}{$lang}, $percent_po_u{$domain}{$lang};
415     printf HTML "<td align=right>%d</td>", $po_total{$domain};
416     print HTML "</tr>\n";
417     }
418     print HTML "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><th>Total:</th>";
419     $color_t = get_color ($percent_po_t{'total'}{$lang});
420     $color_f = get_color (100 - $percent_po_f{'total'}{$lang});
421     $color_u = get_color (100 - $percent_po_u{'total'}{$lang});
422     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_t, $po_translated{'total'}{$lang}, $percent_po_t{'total'}{$lang};
423     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_f, $po_fuzzy{'total'}{$lang}, $percent_po_f{'total'}{$lang};
424     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_u, $po_untranslated{'total'}{$lang}, $percent_po_u{'total'}{$lang};
425     printf HTML "<td align=right>%d</td>", $po_total{'total'};
426     print HTML "</tr>\n";
427     }
428     print HTML "</table>\n";
429    
430     # outputs footer
431 joy 1.1 print HTML "<hr><address>Compiled at $date</address>\n";
432     print HTML "</body></html>";
433     close (HTML);
434     }
435     }
436 joy 1.7 print "\n" if ($config{'verbose'});
437 joy 1.1
438     # =============== Creating index.html ===============
439 joy 1.7 print "Creating index.html... " if ($config{'verbose'});
440 joy 1.1
441     open (HTML, ">$config{'htmldir'}/index.html")
442     || die "Can't open $config{'htmldir'}/index.html";
443    
444 barbier 1.41 printf HTML "<html>\n<head><title>%s</title></head>\n<body bgcolor=\"#ffffff\">\n", $config{'title'};
445     printf HTML "<h1 align=\"center\">%s</h1>\n", $config{'title'};
446 joy 1.1
447 joy 1.45 print HTML "<h2>Translated web pages</h2>\n";
448 alfie 1.52 printf HTML "<p>There are %d pages to translate.</p>\n",($wml{'english'}+$untranslated{'english'});
449 french 1.43
450 joy 1.1 print HTML $border_head;
451 barbier 1.41 print HTML "<table width=\"100%\" border=0 bgcolor=\"#cdc9c9\">\n";
452 joy 1.8 print HTML "<tr><th>Language</th><th>Translations</th><th>Up to date</th><th>Outdated</th><th>Not translated</th></tr>\n";
453 joy 1.14 foreach $lang (@search_in) {
454 joy 1.1 $l = $langs{$lang};
455 joy 1.8 $l = "zh-cn" if ($l eq "zh"); # kludge
456 joy 1.4
457 joy 1.18 $color_a = get_color ($percent_a{$lang});
458     $color_t = get_color ($percent_t{$lang});
459 peterk 1.35 $color_o = get_color (100 - $percent_o{$lang});
460     $color_u = get_color (100 - $percent_u{$lang});
461 joy 1.4
462     print HTML "<tr>";
463 joy 1.13 printf HTML "<td><a href=\"%s.html\">%s</a> (%s)</td>", $l, ucfirst $lang, $l;
464 joy 1.18 printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_a, $wml{$lang}, $percent_a{$lang};
465 kraai 1.26 printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_t, $translated{$lang}, $percent_t{$lang};
466     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_o, $outdated{$lang}, $percent_o{$lang};
467     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_u, $untranslated{$lang}, $percent_u{$lang};
468 joy 1.4 print HTML "</tr>\n",
469 joy 1.1 }
470 barbier 1.41 print HTML "</table>\n";
471 barbier 1.40 print HTML $border_foot;
472 joy 1.1
473 joy 1.45 print HTML "<h2>Translated templates (gettext files)</h2>\n";
474 alfie 1.52 printf HTML "<p>There are %d strings to translate.</p>\n",$po_total{'total'};
475 barbier 1.40 print HTML $border_head;
476 barbier 1.41 print HTML "<table width=\"100%\" border=0 bgcolor=\"#cdc9c9\">\n";
477 french 1.51 print HTML "<tr><th>Language</th><th>Up to date</th><th>Fuzzy</th><th>Not translated</th></tr>\n";
478 barbier 1.40 foreach $lang (@search_in) {
479     next if $lang eq 'english';
480     $l = $langs{$lang};
481     $l = "zh-cn" if ($l eq "zh"); # kludge
482    
483 french 1.43 print HTML "<tr>";
484     printf HTML "<td><a href=\"%s.html#gettext\">%s</a> (%s)</td>", $l, ucfirst $lang, $l;
485     $color_t = get_color ($percent_po_t{'total'}{$lang});
486     $color_f = get_color (100 - $percent_po_f{'total'}{$lang});
487     $color_u = get_color (100 - $percent_po_u{'total'}{$lang});
488     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_t, $po_translated{'total'}{$lang}, $percent_po_t{'total'}{$lang};
489     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_f, $po_fuzzy{'total'}{$lang}, $percent_po_f{'total'}{$lang};
490     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_u, $po_untranslated{'total'}{$lang}, $percent_po_u{'total'}{$lang};
491     print HTML "</tr>\n";
492     }
493 barbier 1.40
494 barbier 1.41 print HTML "</table>\n";
495 joy 1.1 print HTML $border_foot;
496    
497 barbier 1.41 print HTML "<p><hr noshade size=1 width=\"100%\">\n";
498 joy 1.4 print HTML "<p>Created with <a href=\"http://cvs.debian.org/webwml/stattrans.pl?cvsroot=webwml\">webwml-stattrans</a> at $date\n";
499 joy 1.3 print HTML "</body></html>\n";
500 joy 1.1 close (HTML);
501    
502 joy 1.7 print "done.\n" if ($config{'verbose'});
503 joy 1.1
504     # Note:
505     # Translated pages on ll.html may be higher than in index.html.
506     # This is due to the fact that some english pages were removed.
507    
508     # printf "%s\n", join ("\n", keys %version);
509     # printf "%s - %s\n", $version{'german/devel/index'}, $version{'english/devel/index'};

  ViewVC Help
Powered by ViewVC 1.1.5