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

Diff of /webwml/stattrans.pl

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

revision 1.22 by joy, Sun Jul 22 17:03:09 2001 UTC revision 1.58 by barbier, Fri Jan 23 18:26:24 2004 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 19  Line 19 
19    
20  use POSIX qw(strftime);  use POSIX qw(strftime);
21  use Getopt::Std;  use Getopt::Std;
22    
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  $| = 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:');  getopts('h:w:p:t:vd:l:') || die;
40    #  Replace filename globbing by Perl regexps
41    $opt_p =~ s/\./\\./g;
42    $opt_p =~ s/\?/./g;
43    $opt_p =~ s/\*/.*/g;
44    $opt_p =~ s/$/\$/g;
45  %config = (  %config = (
46             'htmldir' => $opt_h,             'htmldir' => $opt_h,
47             'wmldir'  => $opt_w,             'wmldir'  => $opt_w,
48             'wmlpat'  => $opt_p,             'wmlpat'  => $opt_p,
49             'title'   => $opt_t,             'title'   => $opt_t,
50             'verbose' => $opt_v,             'verbose' => $opt_v,
51             'diff'    => $opt_d,             'difftype'=> $opt_d,
52             );             );
53    
54  $max_versions = 5;  my $l = Webwml::Langs->new($opt_w);
55  $min_versions = 1;  my %langs = $l->name_iso();
56    
57    my $transignore = Webwml::TransIgnore->new($opt_w);
58    
59  # from english/template/debian/languages.wml  my $cvs = Local::Cvsinfo->new();
60  # TODO: Needs to be synced frequently or fixed so it's automatic  $cvs->options(
61  my %langs = ( english    => "en",          recursive => 1,
62  #             arabic     => "ar",          matchfile => [ $config{'wmlpat'} ],
63                catalan    => "ca",          skipdir   => [ "template" ],
               danish     => "da",  
               german     => "de",  
               greek      => "el",  
               esperanto  => "eo",  
               spanish    => "es",  
               finnish    => "fi",  
               french     => "fr",  
               croatian   => "hr",  
               hungarian  => "hu",  
               italian    => "it",  
               japanese   => "ja",  
               korean     => "ko",  
               dutch      => "nl",  
               norwegian  => "no",  
               polish     => "pl",  
               portuguese => "pt",  
               romanian   => "ro",  
               russian    => "ru",  
               swedish    => "sv",  
               turkish    => "tr",  
               chinese    => "zh",  
64  );  );
65    $cvs->readinfo("$config{'wmldir'}/english");
66    foreach (@{$transignore->global()}) {
67            $cvs->removefile("$config{'wmldir'}/english/$_");
68    }
69    
70  $border_head = "<table width=95% align=center border=0 cellpadding=0 cellspacing=0><tr bgcolor=#000000><td>"  my $altcvs = Local::Cvsinfo->new();
71                ."<table width=100% border=0 cellpadding=0 cellspacing=1><tr bgcolor=#ffffff><td>";  $altcvs->options(
72  $border_foot = "</td></tr></table></td></tr></table>";          recursive => 1,
73            matchfile => [ $config{'wmlpat'} ],
74            skipdir   => [ "template" ],
75    );
76    
77    $max_versions = 5;
78    $min_versions = 1;
79    
80  $date = strftime "%a %b %e %H:%M:%S %Y %z", localtime;  $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    $border_foot = "</td></tr></table></td></tr></table>";
83    
 sub get_cvs_version  
 {  
     my ($dir, $wmlfile) = @_;  
     my $file;  
     my @comp;  
     my $version;  
   
     @comp = split (/\//, "$dir/$wmlfile");  
     pop @comp;  
     $dir = join ("/", @comp);  
   
     @comp = split (/\//, "$wmlfile");  
     $file = pop @comp;  
   
     if (open (CVS,"$dir/CVS/Entries")) {  
         while (<CVS>) {  
             ($version) = $_ =~ m,/\Q$file\E/([\d\.]*),;  
             last if $version;  
         }  
     }  
84    
85      return $version;  $date = strftime "%a %b %e %H:%M:%S %Y %z", localtime;
 }  
86    
87  sub get_translation_version  my %original;
88  {  my %transversion;
89      my ($dir, $file) = @_;  my %version;
90      my $checktrans;  my %files;
   
     if (open (F, "$dir/$file")) {  
         $checktrans = 0;  
         while (<F>) {  
             chomp;  
             if (/^\#use wml::debian::translation-check/) {  
                 $checktrans = 1;  
                 return $1 if ($_ =~ /translation="([^\" ]+)"/);  
                 last;  
             }  
         }  
         close (F);  
     }  
     return "";  
 }  
91    
92  # Count wml files in given directory  # Count wml files in given directory
93  #  #
# Line 126  sub getwmlfiles Line 95  sub getwmlfiles
95  {  {
96      my $lang = shift;      my $lang = shift;
97      my $dir = "$config{'wmldir'}/$lang";      my $dir = "$config{'wmldir'}/$lang";
     my $cmd = "find $dir -name \"$config{'wmlpat'}\"";  
98      my $cutfrom = length ($config{'wmldir'})+length($lang)+2;      my $cutfrom = length ($config{'wmldir'})+length($lang)+2;
99      my $count = 0;      my $count = 0;
100      my $is_english = ($lang eq "english")?1:0;      my $is_english = ($lang eq "english")?1:0;
101      my $file, $v;      my ( $file, $v );
102        my @listfiles;
103    
104      print "$lang " if ($config{verbose});      print "$lang " if ($config{verbose});
105      die "$0: can't find $dir!\n" if (! -d "$dir");      die "$0: can't find $dir!\n" if (! -d "$dir");
106      open (FIND, "$cmd|") || die "Can't read from $cmd";      if ($is_english) {
107      while (<FIND>) {          @listfiles = @{$cvs->files()};
108          # XXX this list of exceptions needs to be maintained XXX      } else {
109          next if (/\/sitemap\.wml/);          $altcvs->reset();
110          next if (/\/template\//);          $altcvs->readinfo($dir);
111          next if (/\/MailingLists\/(un)?subscribe\.wml/);          @listfiles = @{$altcvs->files()};
112          next if (/\/international\/l10n\/scripts\/l10nheader\.wml/);      }
113          chomp;      foreach my $f (@listfiles) {
114          $file = substr ($_, $cutfrom);          $file = substr ($f, $cutfrom);
115          $file =~ s/\.wml$//;          next if $transignore->is_global($file);
116            $files{$file} = 1;
117          $wmlfiles{$lang} .= " " . $file;          $wmlfiles{$lang} .= " " . $file;
118            my $transcheck = Webwml::TransCheck->new("$dir/$file");
119            if ($transcheck->revision()) {
120                $transversion{"$lang/$file"} = $transcheck->revision();
121                $original{"$lang/$file"} ||= $transcheck->original();
122            }
123          if ($is_english) {          if ($is_english) {
124              $version{"$lang/$file"} = get_cvs_version ($dir, "$file.wml");              $version{"$lang/$file"} = $cvs->revision($f);
125          } else {          } else {
126              $version{"$lang/$file"} = get_translation_version ($dir, "$file.wml");              $version{"$lang/$file"} = $altcvs->revision($f);
127                if (!$transcheck->revision()) {
128                    $original{"english/$file"} = $lang;
129                    $transversion{"english/$file"} ||= "1.1";
130                }
131            }
132            if ($transcheck->maintainer()) {
133                $maintainer{"$lang/$file"} = $transcheck->maintainer();
134          }          }
135          $count++;          $count++;
136      }      }
     close (FIND);  
137      $wmlfiles{$lang} .= " ";      $wmlfiles{$lang} .= " ";
138      $wml{$lang} = $count;      $wml{$lang} = $count;
139  }  }
140    
141  sub get_color  sub get_color
142  {  {
# Line 171  sub get_color Line 152  sub get_color
152  sub check_translation  sub check_translation
153  {  {
154      my ($translation, $version, $file) = @_;      my ($translation, $version, $file) = @_;
155      my @version_numbers, $major_number, $last_number;      my ( @version_numbers, $major_number, $last_number );
156      my @translation_numbers, $major_translated_number, $last_translated_number;      my ( @translation_numbers, $major_translated_number, $last_translated_number );
157    
158      if ($version ne "" && $translation ne "") {      if ( $version && $translation ) {
159          @version_numbers = split /\./,$version;          @version_numbers = split /\./,$version;
160          $major_number = @version_numbers[0];          $major_number = $version_numbers[0];
161          $last_number = pop @version_numbers;          $last_number = pop @version_numbers;
162          die "Invalid CVS revision for $file: $version\n"          die "Invalid CVS revision for $file: $version\n"
163              unless ($major_number =~ /\d+/ && $last_number =~ /\d+/);              unless ($major_number =~ /\d+/ && $last_number =~ /\d+/);
164    
165          @translation_numbers = split /\./,$translation;          @translation_numbers = split /\./,$translation;
166          $major_translated_number = @translation_numbers[0];          $major_translated_number = $translation_numbers[0];
167          $last_translated_number = pop @translation_numbers;          $last_translated_number = pop @translation_numbers;
168          die "Invalid translation revision for $file: $translation\n"          die "Invalid translation revision for $file: $translation\n"
169              unless ($major_translated_number =~ /\d+/ && $last_translated_number =~ /\d+/);              unless ($major_translated_number =~ /\d+/ && $last_translated_number =~ /\d+/);
# Line 191  sub check_translation Line 172  sub check_translation
172          # 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
173          # From translation-check.wml          # From translation-check.wml
174    
175          if ($version eq "") {          if ( $major_number != $major_translated_number ) {
             return "The original no longer exists";  
         } elsif ( $major_number != $major_translated_number ) {  
176              return "This translation is too out of date";              return "This translation is too out of date";
177          } elsif ( $last_number - $last_translated_number >= $max_versions ) {          } elsif ( $last_number - $last_translated_number >= $max_versions ) {
178              return "This translation is too out of date";              return "This translation is too out of date";
179          } elsif ( $last_number - $last_translated_number >= $min_versions ) {          } elsif ( $last_number - $last_translated_number >= $min_versions ) {
180              return "The original is newer than this translation";              return "The original is newer than this translation";
181          }          }
182        } elsif ( !$version && $transversion) {
183            return "The original no longer exists";
184      }      }
185      return "";      return "";
186  }  }
187    
188  print "Collecting data in: " if ($config{'verbose'});  print "Collecting data in: " if ($config{'verbose'});
189  if ($opt_l) {  if ($opt_l) {
   getwmlfiles ('english');  
190    getwmlfiles ($opt_l);    getwmlfiles ($opt_l);
 } else {  
191    getwmlfiles ('english');    getwmlfiles ('english');
192    } else {
193    foreach $lang (keys %langs) {    foreach $lang (keys %langs) {
     next if ($lang eq "english");  
194      getwmlfiles ($lang);      getwmlfiles ($lang);
195    }    }
196  }  }
197  print "\n" if ($config{'verbose'});  print "\n" if ($config{'verbose'});
198    
199    my @search_in;
200    if ($opt_l) {
201      @search_in = ( 'english', $opt_l );
202    } else {
203      @search_in = sort keys %langs;
204    }
205    
206    # Compute stats about gettext files
207    print "Computing statistics in gettext files... " if ($config{'verbose'});
208    my ( %po_translated, %po_fuzzy, %po_untranslated, %po_total );
209    my ( %percent_po_t, %percent_po_u, %percent_po_f );
210    foreach $lang (@search_in) {
211        next if $lang eq 'english';
212        $l = $langs{$lang};
213        $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        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    
222            $po_total{$domain} = $po_translated{$domain}{$lang} + $po_fuzzy{$domain}{$lang} + $po_untranslated{$domain}{$lang};
223    
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            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        }
238        $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    }
250    print "done.\n" if ($config{'verbose'});
251    
252  # =============== Create HTML files ===============  # =============== Create HTML files ===============
253  mkdir ($config{'htmldir'}, 02775) if (! -d $config{'htmldir'});  mkdir ($config{'htmldir'}, 02775) if (! -d $config{'htmldir'});
254    
255  @sorted_english = sort (split (/ /, $wmlfiles{'english'}));  my @filenames = sort keys %files;
256    my $nfiles = scalar @filenames;
257    
258  print "Creating files: " if ($config{'verbose'});  print "Creating files: " if ($config{'verbose'});
 my @search_in = ();  
 if ($opt_l) {  
   push @search_in, 'english';  
   push @search_in, $opt_l;  
 } else {  
   @search_in = sort keys %langs;  
 }  
259  foreach $lang (@search_in) {  foreach $lang (@search_in) {
260      $l = $langs{$lang};      $l = $langs{$lang};
261      print "$l.html " if ($config{'verbose'});      print "$l.html " if ($config{'verbose'});
# Line 237  foreach $lang (@search_in) { Line 263  foreach $lang (@search_in) {
263    
264      $t_body = $u_body = $o_body = "";      $t_body = $u_body = $o_body = "";
265    
266      foreach $file (@sorted_english) {      # get stats about files
267          next if ($file eq "");      foreach $file (@filenames) {
268            next if ($file eq "");
269          # Translated pages          # Translated pages
270          if (index ($wmlfiles{$lang}, " $file ") >= 0) {          if (index ($wmlfiles{$lang}, " $file ") >= 0) {
271                  if ($file =~ /devel\/wnpp\/wnpp\.wml/) {                  $translated{$lang}++;
272                          $t_body .= sprintf "%s<br>\n", $file;                  $orig = $original{"$lang/$file"} || "english";
                 } else {  
                         $t_body .= sprintf "<a href=\"/%s.%s.html\">%s</a><br>\n", $file, $l, $file;  
                 }  
                 $translated{$lang}++;  
                 next if ($lang eq "english");  
273                  # Outdated translations                  # Outdated translations
274                  $msg = check_translation ($version{"$lang/$file"}, $version{"english/$file"}, "$lang/$file");                  $msg = check_translation ($transversion{"$lang/$file"}, $version{"$orig/$file"}, "$lang/$file");
275                  if (length ($msg)) {                  if (length ($msg)) {
276                          $o_body .= "<tr>";                          $o_body .= "<tr>";
277                          if ($file =~ /devel\/wnpp\/wnpp\.wml/) {                          if (($file !~ /\.wml$/)
278                                  $o_body .= sprintf "<td>%s</td>", $file;                              || ($file eq "devel/wnpp/wnpp.wml")) {
279                                $o_body .= sprintf "<td>%s</td>", $file;
280                          } else {                          } else {
281                                  $o_body .= sprintf "<td><a href=\"/%s.%s.html\">%s</a></td>", $file, $l, $file;                              (my $base = $file) =~ s/\.wml$//;
282                                $o_body .= sprintf "<td><a href=\"/%s.%s.html\">%s</a></td>", $base, $l, $base;
283                          }                          }
284                          $o_body .= sprintf "<td>%s</td>", $version{"$lang/$file"};                          $o_body .= sprintf "<td>%s</td>", $transversion{"$lang/$file"};
285                          $o_body .= sprintf "<td>%s</td>", $version{"english/$file"};                          $o_body .= sprintf "<td>%s</td>", $version{"$orig/$file"};
286                          $o_body .= sprintf "<td>%s</td>", $msg;                          $o_body .= sprintf "<td>%s</td>", $msg;
287                          $o_body .= sprintf "<td>&nbsp;&nbsp;<a href=\"http://cvs.debian.org/webwml/english/%s.wml.diff\?r1=%s\&r2=%s\&cvsroot=webwml\&diff_format=%s\">%s -> %s</a></td>", $file, $version{"$lang/$file"}, $version{"english/$file"}, $config{'diff_type'}, $version{"$lang/$file"}, $version{"english/$file"};                          $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                            $o_body .= sprintf "<td align=center>%s</td>", $maintainer{"$lang/$file"} || "";
290                          $o_body .= "</tr>\n";                          $o_body .= "</tr>\n";
291                          $outdated{$lang}++;                          $outdated{$lang}++;
292                    # Up-to-date translations
293                    } else {
294                            if (($file !~ /\.wml$/)
295                                || ($file eq "devel/wnpp/wnpp.wml")) {
296                                $t_body .= sprintf "%s<br>\n", $file;
297                            } else {
298                                (my $base = $file) =~ s/\.wml$//;
299                                $t_body .= sprintf "<a href=\"/%s.%s.html\">%s</a><br>\n", $base, $l, $base;
300                            }
301                  }                  }
302          }          }
303          # Untranslated pages          # Untranslated pages
304          else {          else {
305                  if ($file =~ /devel\/wnpp\/wnpp\.wml/) {                  if (($file !~ /\.wml$/)
306                          $u_body .= sprintf "%s<br>\n", $file;                      || ($file eq "devel/wnpp/wnpp.wml")) {
307                        $u_body .= sprintf "%s<br>\n", $file;
308                  } else {                  } else {
309                          $u_body .= sprintf "<a href=\"/%s\">%s</a><br>\n", $file, $file;                      (my $base = $file) =~ s/\.wml$//;
310                        $u_body .= sprintf "<a href=\"/%s\">%s</a><br>\n", $base, $base;
311                  }                  }
312                  $untranslated{$lang}++;                  $untranslated{$lang}++;
313          }          }
314      }      }
315    
316    
317  # this is where we discard the files that the translation directory contains  # this is where we discard the files that the translation directory contains
318  # but which don't exist in the English directory  # but which don't exist in the English directory
319  #   print "extra files: ".$wml{$lang}-$translated{$lang}."\n";  #   print "extra files: ".$wml{$lang}-$translated{$lang}."\n";
320      $wml{$lang} = $translated{$lang};      $wml{$lang} = $translated{$lang};
321      $translated{$lang} = $translated{$lang} - $outdated{$lang};      $translated{$lang} = $translated{$lang} - $outdated{$lang};
322    
323      $percent_a{$lang} = $wml{$lang}/$wml{english} * 100;      if ($nfiles > 0) {
324      $percent_t{$lang} = $translated{$lang}/$wml{english} * 100;          $percent_a{$lang} = int ($wml{$lang}/$nfiles * 100 + .5);
325      $percent_o{$lang} = $outdated{$lang}/$wml{english} * 100;      } else {
326      $percent_u{$lang} = $untranslated{$lang}/$wml{english} * 100;          $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        $percent_o{$lang} = 100 - $percent_t{$lang};
334        $percent_u{$lang} = 100 - $percent_a{$lang};
335    
336      if (open (HTML, ">$config{'htmldir'}/$l.html")) {      if (open (HTML, ">$config{'htmldir'}/$l.html")) {
337          printf HTML "<html><head><title>%s: %s</title></head><body bgcolor=#ffffff>\n", $config{'title'}, ucfirst $lang;          printf HTML "<html><head><title>%s: %s</title></head><body bgcolor=\"#ffffff\">\n", $config{'title'}, ucfirst $lang;
338    
339          $color = get_color ($percent_a{$lang});          $color = get_color ($percent_a{$lang});
340    
341          printf HTML "<table width=100%% cellpadding=2 cellspacing=0 bgcolor=%s>\n", $color;          print HTML "<a name=\"top\"></a>\n";
342            printf HTML "<table width=\"100%%\" cellpadding=2 cellspacing=0 bgcolor=\"%s\">\n", $color;
343    
344          printf HTML "<tr><td colspan=4><h1 align=center>%s: %s</h1></td></tr>", $config{'title'}, ucfirst $lang;          printf HTML "<tr><td colspan=4><h1 align=\"center\">%s: %s</h1></td></tr>", $config{'title'}, ucfirst $lang;
345    
346          print HTML "<tr>\n";          print HTML "<tr>\n";
347          printf HTML "<td align=center width=25%%><b>%d files (%d%%) translated</b></td>", $wml{$lang}, $percent_a{$lang};          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};          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};          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};          printf HTML "<td align=\"center\" width=\"25%%\"><b>%d files (%d%%) not translated</b></td>", $untranslated{$lang}, $percent_u{$lang};
351          print HTML "</tr>\n";          print HTML "</tr>\n";
352          print HTML "</table>\n";          print HTML "</table>\n";
353    
354          print HTML "<p><a href=\"./\">Index</a><p>\n";          # Make the table of content
355          print HTML "<p><a href=\"../\">Working on the website</a><p>\n";          print HTML "<h3>Table of Contents</h3>\n";
356            print HTML "<p><a href=\"./\">Back to index of languages</a></p>\n";
357            print HTML "<br /><a href=\"../\">Working on the website</a>\n";
358          if ($o_body) {          if ($o_body) {
359              print HTML "<h3>Outdated translations:</h3>";              print HTML "<br /><a href=\"#outdated\">Outdated translations</a>\n";
360            }
361            if ($u_body) {
362                print HTML "<br /><a href=\"#untranslated\">Pages not translated</a>\n";
363            }
364            if ($t_body) {
365                print HTML "<br /><a href=\"#uptodate\">Translations up to date</a>\n";
366            }
367            if ($lang ne 'english') {
368                print HTML "<br /><a href=\"#gettext\">Translations of templates (gettext files)</a>\n";
369            }
370       print HTML "</p>\n";
371    
372            # outputs the content
373            if ($o_body) {
374                print HTML "<h3><a name='outdated'>Outdated translations</a>: <a href='#top'>(top)</a></h3>\n";
375              print HTML "<table border=0 cellpadding=1 cellspacing=1>\n";              print HTML "<table border=0 cellpadding=1 cellspacing=1>\n";
376              print HTML "<tr><th>File</th><th>Translated</th><th>English</th><th>Comment</th>";              print HTML "<tr><th>File</th><th>Translated</th><th>Origin</th><th>Comment</th>";
377              if ($opt_d eq "u") { print HTML "<th>Unified diff</th>"; }              if ($opt_d eq "u") { print HTML "<th>Unified diff</th>"; }
378              elsif ($opt_d eq "h") { print HTML "<th>Colored diff</th>"; }              elsif ($opt_d eq "h") { print HTML "<th>Colored diff</th>"; }
379              else { print HTML "<th>Diff</th>"; }              else { print HTML "<th>Diff</th>"; }
380                print HTML "<th>Log</th>";
381                print HTML "<th>Maintainer</th>";
382              print HTML "</tr>\n";              print HTML "</tr>\n";
383              print HTML $o_body;              print HTML $o_body;
384              print HTML "</table>\n";              print HTML "</table>\n";
385          }          }
386          if ($u_body) {          if ($u_body) {
387              print HTML "<h3>Pages not translated:</h3>";              print HTML "<h3><a name='untranslated'>Pages not translated</a>: <a href='#top'>(top)</a></h3>\n";
388              print HTML $u_body;              print HTML $u_body;
389          }          }
390          if ($t_body) {          if ($t_body) {
391              print HTML "<h3>Translations up to date:</h3>";              print HTML "<h3><a name='uptodate'>Translations up to date</a>: <a href='#top'>(top)</a></h3>\n";
392              print HTML $t_body;              print HTML $t_body;
393          }          }
394            # outputs the gettext stats
395            if ($lang ne 'english') {
396                print HTML "<h3><a name='gettext'>Translations of templates (gettext files)</a>: <a href='#top'>(top)</a></h3>\n";
397    #           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";          print HTML "</table>\n";
429    
430            # outputs footer
431          print HTML "<hr><address>Compiled at $date</address>\n";          print HTML "<hr><address>Compiled at $date</address>\n";
432          print HTML "</body></html>";          print HTML "</body></html>";
433          close (HTML);          close (HTML);
# Line 341  print "Creating index.html... " if ($con Line 441  print "Creating index.html... " if ($con
441  open (HTML, ">$config{'htmldir'}/index.html")  open (HTML, ">$config{'htmldir'}/index.html")
442      || die "Can't open $config{'htmldir'}/index.html";      || die "Can't open $config{'htmldir'}/index.html";
443    
444  printf HTML "<html>\n<head><title>%s</title></head>\n<body bgcolor=#ffffff>\n", $config{'title'};  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'};  printf HTML "<h1 align=\"center\">%s</h1>\n", $config{'title'};
446    
447    print HTML "<h2>Translated web pages</h2>\n";
448    printf HTML "<p>There are %d pages to translate.</p>\n",($wml{'english'}+$untranslated{'english'});
449    
450  print HTML $border_head;  print HTML $border_head;
451  print HTML "<table width=100% border=0 bgcolor=\"#cdc9c9\">\n";  print HTML "<table width=\"100%\" border=0 bgcolor=\"#cdc9c9\">\n";
452  print HTML "<tr><th>Language</th><th>Translations</th><th>Up to date</th><th>Outdated</th><th>Not translated</th></tr>\n";  print HTML "<tr><th>Language</th><th>Translations</th><th>Up to date</th><th>Outdated</th><th>Not translated</th></tr>\n";
453  foreach $lang (@search_in) {  foreach $lang (@search_in) {
454      $l = $langs{$lang};      $l = $langs{$lang};
# Line 353  foreach $lang (@search_in) { Line 456  foreach $lang (@search_in) {
456    
457      $color_a = get_color ($percent_a{$lang});      $color_a = get_color ($percent_a{$lang});
458      $color_t = get_color ($percent_t{$lang});      $color_t = get_color ($percent_t{$lang});
459      $color_o = get_color ($percent_o{$lang});      $color_o = get_color (100 - $percent_o{$lang});
460      $color_u = get_color ($percent_u{$lang});      $color_u = get_color (100 - $percent_u{$lang});
461    
462      print HTML "<tr>";      print HTML "<tr>";
463      printf HTML "<td><a href=\"%s.html\">%s</a> (%s)</td>", $l, ucfirst $lang, $l;      printf HTML "<td><a href=\"%s.html\">%s</a> (%s)</td>", $l, ucfirst $lang, $l;
464      printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_a, $wml{$lang}, $percent_a{$lang};      printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_a, $wml{$lang}, $percent_a{$lang};
465      if ($l ne "en") {      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_t, $translated{$lang}, $percent_t{$lang};      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_o, $outdated{$lang}, $percent_o{$lang};      printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_u, $untranslated{$lang}, $percent_u{$lang};
       printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_u, $untranslated{$lang}, $percent_u{$lang};  
     } else {  
       print HTML "<td bgcolor=\"#00FF00\" align=right>-</td><td bgcolor=\"#00FF00\" align=right>-</td><td bgcolor=\"#FF0000\" align=right>-</td>";  
     }  
468      print HTML "</tr>\n",      print HTML "</tr>\n",
469  }  }
470    print HTML "</table>\n";
 print HTML "</tr></table>";  
471  print HTML $border_foot;  print HTML $border_foot;
472    
473    print HTML "<h2>Translated templates (gettext files)</h2>\n";
474    printf HTML "<p>There are %d strings to translate.</p>\n",$po_total{'total'};
475    print HTML $border_head;
476    print HTML "<table width=\"100%\" border=0 bgcolor=\"#cdc9c9\">\n";
477    print HTML "<tr><th>Language</th><th>Up to date</th><th>Fuzzy</th><th>Not translated</th></tr>\n";
478    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        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    
494  print HTML "</table>\n";  print HTML "</table>\n";
495  print HTML "<p><hr noshade size=1 width=100%>\n";  print HTML $border_foot;
496    
497    print HTML "<p><hr noshade size=1 width=\"100%\">\n";
498  print HTML "<p>Created with <a href=\"http://cvs.debian.org/webwml/stattrans.pl?cvsroot=webwml\">webwml-stattrans</a> at $date\n";  print HTML "<p>Created with <a href=\"http://cvs.debian.org/webwml/stattrans.pl?cvsroot=webwml\">webwml-stattrans</a> at $date\n";
499  print HTML "</body></html>\n";  print HTML "</body></html>\n";
500  close (HTML);  close (HTML);

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.58

  ViewVC Help
Powered by ViewVC 1.1.5