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

Diff of /webwml/stattrans.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.81

  ViewVC Help
Powered by ViewVC 1.1.5