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

Diff of /webwml/stattrans.pl

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

revision 1.69 by djpig, Mon Aug 15 03:25:52 2005 UTC revision 1.70 by bertol, Sun Sep 11 21:00:50 2005 UTC
# Line 88  my %original; Line 88  my %original;
88  my %transversion;  my %transversion;
89  my %version;  my %version;
90  my %files;  my %files;
91    my %sizes;
92    
93                sub format3($) {
94                    $_ = sprintf("%d", shift);
95                    $_ = "&nbsp;&nbsp;$_" if length($_) < 2;
96                    $_ =       "&nbsp;$_" if length($_) < 3;
97                    $_;
98                }
99                sub format5($) {
100                    $_ = sprintf("%.1f", shift);
101                    $_ = "&nbsp;&nbsp;$_" if length($_) < 4;
102                    $_ =       "&nbsp;$_" if length($_) < 5;
103                    $_;
104                }
105  # Count wml files in given directory  # Count wml files in given directory
106  #  #
107  sub getwmlfiles  sub getwmlfiles
# Line 97  sub getwmlfiles Line 110  sub getwmlfiles
110      my $dir = "$config{'wmldir'}/$lang";      my $dir = "$config{'wmldir'}/$lang";
111      my $cutfrom = length ($config{'wmldir'})+length($lang)+2;      my $cutfrom = length ($config{'wmldir'})+length($lang)+2;
112      my $count = 0;      my $count = 0;
113        my $size = 0;
114      my $is_english = ($lang eq "english")?1:0;      my $is_english = ($lang eq "english")?1:0;
115      my ( $file, $v );      my ( $file, $v );
116      my @listfiles;      my @listfiles;
# Line 139  sub getwmlfiles Line 153  sub getwmlfiles
153              $maintainer{"$lang/$file"} = $transcheck->maintainer();              $maintainer{"$lang/$file"} = $transcheck->maintainer();
154          }          }
155          $count++;          $count++;
156            $sizes{$file} = (stat "".($original{"english/$file"}||"english")."/".$file)[7];
157            $size += $sizes{$file};
158      }      }
159      $wmlfiles{$lang} .= " ";      $wmlfiles{$lang} .= " ";
160      $wml{$lang} = $count;      $wml{$lang} = $count;
161        $wml_s{$lang} = $size;
162  }  }
163    
164  sub get_color  sub get_color
# Line 261  mkdir ($config{'htmldir'}, 02775) if (! Line 278  mkdir ($config{'htmldir'}, 02775) if (!
278    
279  my @filenames = sort keys %files;  my @filenames = sort keys %files;
280  my $nfiles = scalar @filenames;  my $nfiles = scalar @filenames;
281    $nsize += $sizes{$_} foreach (@filenames);
282    
283  print "Creating files: " if ($config{'verbose'});  print "Creating files: " if ($config{'verbose'});
284  foreach $lang (@search_in) {  foreach $lang (@search_in) {
# Line 278  foreach $lang (@search_in) { Line 296  foreach $lang (@search_in) {
296              # Translated pages              # Translated pages
297              if (index ($wmlfiles{$lang}, " $file ") >= 0) {              if (index ($wmlfiles{$lang}, " $file ") >= 0) {
298                  $translated{$lang}++;                  $translated{$lang}++;
299                    $translated_s{$lang} += $sizes{$file};
300                  $orig = $original{"$lang/$file"} || "english";                  $orig = $original{"$lang/$file"} || "english";
301                  # Outdated translations                  # Outdated translations
302                  $msg = check_translation ($transversion{"$lang/$file"}, $version{"$orig/$file"}, "$lang/$file");                  $msg = check_translation ($transversion{"$lang/$file"}, $version{"$orig/$file"}, "$lang/$file");
# Line 302  foreach $lang (@search_in) { Line 321  foreach $lang (@search_in) {
321                      $o_body .= sprintf "<td align=center>%s</td>", $maintainer{"$lang/$file"} || "";                      $o_body .= sprintf "<td align=center>%s</td>", $maintainer{"$lang/$file"} || "";
322                      $o_body .= "</tr>\n";                      $o_body .= "</tr>\n";
323                      $outdated{$lang}++;                      $outdated{$lang}++;
324                        $outdated_s{$lang} += $sizes{$file};
325                  # Up-to-date translations                  # Up-to-date translations
326                  } else {                  } else {
327                      if (($file !~ /\.wml$/)                      if (($file !~ /\.wml$/)
# Line 317  foreach $lang (@search_in) { Line 337  foreach $lang (@search_in) {
337              else {              else {
338                  if (($file !~ /\.wml$/)                  if (($file !~ /\.wml$/)
339                      || ($file eq "devel/wnpp/wnpp.wml")) {                      || ($file eq "devel/wnpp/wnpp.wml")) {
340                      $u_body .= sprintf "%s<br>\n", $file;                      $u_body .= sprintf "<tr><td>%s</td><td>&nbsp;</td></tr>\n", $file;
341                  } else {                  } else {
342                      (my $base = $file) =~ s/\.wml$//;                      (my $base = $file) =~ s/\.wml$//;
343                      $u_body .= sprintf "<a href=\"/%s\">%s</a><br>\n", $base, $base;                      $u_body .= sprintf "<tr><td><a href=\"/%s\">%s</a></td><td align=\"right\">%d</td><td>(%.2f&nbsp;&permil;)</td></tr>\n", $base, $base, $sizes{$file}, int($sizes{$file}/$nsize * 100000 + .5) / 100;
344                  }                  }
345                  $untranslated{$lang}++;                  $untranslated{$lang}++;
346                    $untranslated_s{$lang} += $sizes{$file};
347              }              }
348          }          }
349    
# Line 331  foreach $lang (@search_in) { Line 352  foreach $lang (@search_in) {
352          # but which don't exist in the English directory          # but which don't exist in the English directory
353          #   print "extra files: ".$wml{$lang}-$translated{$lang}."\n";          #   print "extra files: ".$wml{$lang}-$translated{$lang}."\n";
354          $wml{$lang} = $translated{$lang};          $wml{$lang} = $translated{$lang};
355            $wml_s{$lang} = $translated_s{$lang};
356          $translated{$lang} = $translated{$lang} - $outdated{$lang};          $translated{$lang} = $translated{$lang} - $outdated{$lang};
357            $translated_s{$lang} = $translated_s{$lang} - $outdated_s{$lang};
358    
359          if ($nfiles > 0) {          if ($nfiles > 0) {
360              $percent_a{$lang} = int ($wml{$lang}/$nfiles * 100 + .5);              $percent_a{$lang} = int ($wml{$lang}/$nfiles * 100 + .5);
361                $percent_as{$lang} = (int ($wml_s{$lang}/$nsize * 1000 + .5))/10;
362          } else {          } else {
363              $percent_a{$lang} = 0;              $percent_a{$lang} = 0;
364                $percent_as{$lang} = 0;
365          }          }
366          if ($wml{$lang} > 0) {          if ($wml{$lang} > 0) {
367              $percent_t{$lang} = int ($translated{$lang}/$wml{$lang} * 100 + .5);              $percent_t{$lang} = int ($translated{$lang}/$wml{$lang} * 100 + .5);
368                $percent_ts{$lang} = (int ($translated_s{$lang}/($wml_s{$lang}+1) * 1000 + .5))/10;
369          } else {          } else {
370              $percent_t{$lang} = 0;              $percent_t{$lang} = 0;
371                $percent_ts{$lang} = 0;
372          }          }
373          $percent_o{$lang} = 100 - $percent_t{$lang};          $percent_o{$lang} = 100 - $percent_t{$lang};
374            $percent_os{$lang} = 100 - $percent_ts{$lang};
375          $percent_u{$lang} = 100 - $percent_a{$lang};          $percent_u{$lang} = 100 - $percent_a{$lang};
376            $percent_us{$lang} = 100 - $percent_as{$lang};
377    
378          if (open (HTML, ">$config{'htmldir'}/$l.html")) {          if (open (HTML, ">$config{'htmldir'}/$l.html")) {
379              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;
# Line 357  foreach $lang (@search_in) { Line 386  foreach $lang (@search_in) {
386              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;
387    
388              print HTML "<tr>\n";              print HTML "<tr>\n";
389              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};
390              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};
391              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};
392              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};
393              print HTML "</tr>\n";              print HTML "</tr>\n";
394                print HTML "<tr>\n";
395                printf HTML "<td align=\"center\" width=\"25%%\"><b>%d bytes (%.1f%%) translated</b></td>",     $wml_s{$lang},        $percent_as{$lang};
396                printf HTML "<td align=\"center\" width=\"25%%\"><b>%d bytes (%.1f%%) up to date</b></td>",     $translated_s{$lang}, $percent_ts{$lang};
397                printf HTML "<td align=\"center\" width=\"25%%\"><b>%d bytes (%.1f%%) outdated</b></td>",       $outdated_s{$lang},   $percent_os{$lang};
398                printf HTML "<td align=\"center\" width=\"25%%\"><b>%d bytes (%.1f%%) not translated</b></td>", $nsize-$wml_s{$lang}, $percent_us{$lang};
399                print HTML "</tr>\n";
400              print HTML "</table>\n";              print HTML "</table>\n";
401    
402              # Make the table of content              # Make the table of content
# Line 398  foreach $lang (@search_in) { Line 433  foreach $lang (@search_in) {
433              }              }
434              if ($u_body) {              if ($u_body) {
435                  print HTML "<h3><a name='untranslated'>Pages not translated</a>: <a href='#top'>(top)</a></h3>\n";                  print HTML "<h3><a name='untranslated'>Pages not translated</a>: <a href='#top'>(top)</a></h3>\n";
436                    print HTML "<table>\n";
437                  print HTML $u_body;                  print HTML $u_body;
438                    print HTML "</table>\n";
439              }              }
440              if ($t_body) {              if ($t_body) {
441                  print HTML "<h3><a name='uptodate'>Translations up to date</a>: <a href='#top'>(top)</a></h3>\n";                  print HTML "<h3><a name='uptodate'>Translations up to date</a>: <a href='#top'>(top)</a></h3>\n";
# Line 419  foreach $lang (@search_in) { Line 456  foreach $lang (@search_in) {
456                      $color_u = get_color (100 - $percent_po_u{$domain}{$lang});                      $color_u = get_color (100 - $percent_po_u{$domain}{$lang});
457    
458                      print HTML "<td>$domain.$langs{$lang}.po</td>";                      print HTML "<td>$domain.$langs{$lang}.po</td>";
459                      printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_t, $po_translated{$domain}{$lang}, $percent_po_t{$domain}{$lang};                      printf HTML "<td bgcolor=\"%s\" align=right>%d (%s%%)</td>", $color_t, $po_translated{$domain}{$lang},   $percent_po_t{$domain}{$lang};
460                      printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_f, $po_fuzzy{$domain}{$lang}, $percent_po_f{$domain}{$lang};                      printf HTML "<td bgcolor=\"%s\" align=right>%d (%s%%)</td>", $color_f, $po_fuzzy{$domain}{$lang},        $percent_po_f{$domain}{$lang};
461                      printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_u, $po_untranslated{$domain}{$lang}, $percent_po_u{$domain}{$lang};                      printf HTML "<td bgcolor=\"%s\" align=right>%d (%s%%)</td>", $color_u, $po_untranslated{$domain}{$lang}, $percent_po_u{$domain}{$lang};
462                      printf HTML "<td align=right>%d</td>", $po_total{$domain};                      printf HTML "<td align=right>%d</td>", $po_total{$domain};
463                      print HTML "</tr>\n";                      print HTML "</tr>\n";
464                  }                  }
# Line 472  foreach $lang (@search_in) { Line 509  foreach $lang (@search_in) {
509    
510          print HTML "<tr>";          print HTML "<tr>";
511          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;
512          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%d%%)</td>", $color_a, $wml{$lang}, $percent_a{$lang};          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_a, $wml{$lang},          format3($percent_a{$lang});
513          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%d%%)</td>", $color_t, $translated{$lang}, $percent_t{$lang};          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_t, $translated{$lang},   format3($percent_t{$lang});
514          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%d%%)</td>", $color_o, $outdated{$lang}, $percent_o{$lang};          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_o, $outdated{$lang},     format3($percent_o{$lang});
515          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%d%%)</td>", $color_u, $untranslated{$lang}, $percent_u{$lang};          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_u, $untranslated{$lang}, format3($percent_u{$lang});
516          print HTML "</tr>\n";          print HTML "</tr>\n";
517      }      }
518  }  }
519  print HTML "</table>\n";  print HTML "</table>\n";
520  print HTML $border_foot;  print HTML $border_foot;
521    
522    print HTML "<h2>Translated web pages (by size)</h2>\n";
523    printf HTML "<p>There are %d bytes to translate.</p>\n",($wml_s{'english'}+$untranslated_s{'english'});
524    
525    print HTML $border_head;
526    print HTML "<table width=\"100%\" border=0 bgcolor=\"#cdc9c9\">\n";
527    print HTML "<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";
528    
529    foreach $lang (@search_in) {
530        my @processed_langs = ($langs{$lang});
531        @processed_langs = ("zh-cn", "zh-tw") if $langs{$lang} eq "zh";
532        foreach $l (@processed_langs) {
533            $color_a = get_color ($percent_a{$lang});
534            $color_t = get_color ($percent_t{$lang});
535            $color_o = get_color (100 - $percent_o{$lang});
536            $color_u = get_color (100 - $percent_u{$lang});
537    
538            print HTML "<tr>";
539            printf HTML "<td><a href=\"%s.html\">%s</a> (%s)</td>", $l, ucfirst $lang, $l;
540            printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_a, $wml_s{$lang},                   format5($percent_as{$lang});
541            printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_t, $translated_s{$lang},            format5($percent_ts{$lang});
542            printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_o, $outdated_s{$lang},              format5($percent_os{$lang});
543            printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_u, $wml_s{"english"}-$wml_s{$lang}, format5($percent_us{$lang});
544            print HTML "</tr>\n";
545        }
546    }
547    print HTML "</table>\n";
548    print HTML $border_foot;
549    
550  print HTML "<h2>Translated templates (gettext files)</h2>\n";  print HTML "<h2>Translated templates (gettext files)</h2>\n";
551  printf HTML "<p>There are %d strings to translate.</p>\n",$po_total{'total'};  printf HTML "<p>There are %d strings to translate.</p>\n",$po_total{'total'};
552  print HTML $border_head;  print HTML $border_head;
# Line 497  foreach $lang (@search_in) { Line 562  foreach $lang (@search_in) {
562          $color_t = get_color ($percent_po_t{'total'}{$lang});          $color_t = get_color ($percent_po_t{'total'}{$lang});
563          $color_f = get_color (100 - $percent_po_f{'total'}{$lang});          $color_f = get_color (100 - $percent_po_f{'total'}{$lang});
564          $color_u = get_color (100 - $percent_po_u{'total'}{$lang});          $color_u = get_color (100 - $percent_po_u{'total'}{$lang});
565          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%d%%)</td>", $color_t, $po_translated{'total'}{$lang}, $percent_po_t{'total'}{$lang};          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_t, $po_translated{'total'}{$lang},   format3($percent_po_t{'total'}{$lang});
566          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%d%%)</td>", $color_f, $po_fuzzy{'total'}{$lang}, $percent_po_f{'total'}{$lang};          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_f, $po_fuzzy{'total'}{$lang},        format3($percent_po_f{'total'}{$lang});
567          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%d%%)</td>", $color_u, $po_untranslated{'total'}{$lang}, $percent_po_u{'total'}{$lang};          printf HTML "<td bgcolor=\"%s\" align=right>%d</td><td>(%s%%)</td>", $color_u, $po_untranslated{'total'}{$lang}, format3($percent_po_u{'total'}{$lang});
568          print HTML "</tr>\n";          print HTML "</tr>\n";
569      }      }
570  }  }

Legend:
Removed from v.1.69  
changed lines
  Added in v.1.70

  ViewVC Help
Powered by ViewVC 1.1.5