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