stattrans.pl 37.8 KB
Newer Older
1 2
#! /usr/bin/perl

3
#   webwml-stattrans - Debian web site translation statistics
4 5 6 7 8 9 10 11 12 13 14 15 16 17
#   Copyright (c) 2001  Martin Schulze <joey@debian.org> and others

#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.

#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.

#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
18
#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 20

use POSIX qw(strftime);
Josip Rodin's avatar
Josip Rodin committed
21
use Getopt::Std;
22 23 24

#    These modules reside under webwml/Perl
use lib ($0 =~ m|(.*)/|, $1 or ".") ."/Perl";
25
use Local::VCS ':all';
26 27 28
use Webwml::Langs;
use Webwml::TransCheck;
use Webwml::TransIgnore;
29
use Debian::L10n::Db ('%LanguageList');
30
use Net::Domain qw(hostfqdn);
31
use Data::Dumper;
32
use JSON;
33

34
$| = 1;
Josip Rodin's avatar
Josip Rodin committed
35

36
$opt_h = "/srv/www.debian.org/webwml/english/devel/website/stats";
37
$opt_w = "/srv/www.debian.org/webwml";
38
$opt_p = "*.(wml|src)";
39
$opt_t = '<stats_title>';
Josip Rodin's avatar
Josip Rodin committed
40
$opt_v = 0;
41
$opt_d = "u";
42
$opt_l = undef;
43
$opt_b = ""; # Base URL, if not debian.org
44 45
# Should we try to repair any broken translation hash references?
$opt_r = 0;
46 47
# path of web stats JSON data
$opt_f = "/srv/www.debian.org/webwml/stats.json";
48
getopts('h:w:b:p:t:vd:l:f:r') || die;
49
#  Replace filename globbing by Perl regexps
50
$opt_p =~ s/\./\\./g;
51 52 53
$opt_p =~ s/\?/./g;
$opt_p =~ s/\*/.*/g;
$opt_p =~ s/$/\$/g;
54
%config = (
Josip Rodin's avatar
Josip Rodin committed
55 56 57 58 59
	   'htmldir' => $opt_h,
	   'wmldir'  => $opt_w,
	   'wmlpat'  => $opt_p,
	   'title'   => $opt_t,
	   'verbose' => $opt_v,
60
	   'difftype'=> $opt_d,
61
           'hit_file'=> $opt_f,
62
           'repair'  => $opt_r,
63 64
	   );

65
my $VCSHOST = "salsa";
66
my $VCSBASE = "https://salsa.debian.org/webmaster-team/webwml";
67

68 69
my $l = Webwml::Langs->new($opt_w);
my %langs = $l->name_iso();
70
my $VCS = Local::VCS->new();
71
if ($config{verbose}) {
72
    print "Caching VCS for performance...\n";
73
}
74
$VCS->cache_repo();
75 76 77
if ($config{verbose}) {
    print "   ...done\n";
}
78 79 80

my $transignore = Webwml::TransIgnore->new($opt_w);

81 82 83 84 85 86 87
chdir($config{'wmldir'}) or die "Can't chdir to $config{'wmldir'}: $!\n";

my %rev_info = $VCS->path_info("english",
			     'recursive' => 1,
			     'match_pat' => $config{'wmlpat'},
			     'skip_pat'  => "(template|/devel/website/stats/)");
my $cnt = scalar(keys %rev_info);
88
foreach (@{$transignore->global()}) {
89
	delete $rev_info{"english/$_"};
90
}
91

92 93 94
$max_versions = 5;
$min_versions = 1;

95 96
$date = strftime "%a %b %e %H:%M:%S %Y %z", localtime;

97
my %original;
98 99
my %transversion;
my %version;
100
my %files;
101
my %sizes;
102

103 104
print "Loading the coordination status databases\n" if ($config{verbose});
my %status_db = ();
105 106
opendir (DATADIR, "english/international/l10n/data")
	or die "Cannot open directory english/international/l10n/data: $!\n";
107 108 109 110 111
foreach (readdir (DATADIR)) {
	# Only check the status files
	next unless ($_ =~ m/^status\.(.*)$/);
	my $l = $1;
	next if (!defined $LanguageList{uc $l});
112
	if (-r "english/international/l10n/data/status.$l") {
113
		$status_db{$LanguageList{uc $l}} = Debian::L10n::Db->new();
114
		$status_db{$LanguageList{uc $l}}->read("english/international/l10n/data/status.$l", 0);
115 116 117 118 119 120 121 122 123 124 125 126 127 128
	}
}
closedir (DATADIR);

sub linklist {
	my ($file, $lang) = @_;
	my $add = "";
	if ($status_db{$lang}->has_package('www.debian.org')
	and $status_db{$lang}->has_status('www.debian.org')) {
		foreach my $statusline (@{$status_db{$lang}->status('www.debian.org')}) {
			my ($type, $statfile, $date, $status, $translator, $list, $url, $bug_nb) = @{$statusline};
			if ($file eq $statfile) {
				$date =~ s/\s*\+0000$//;
				$list =~ /^(\d\d\d\d)-(\d\d)-(\d\d\d\d\d)$/;
129
				$add = "<a href=\"https://lists.debian.org/debian-l10n-$lang/$1/debian-l10n-$lang-$1$2/msg$3.html\">$status</a>";
130 131 132 133 134 135 136 137
				$add = "<td>$add</td><td>$translator</td><td>$date</td>";
			}
		}
	}
	$add = '<td></td><td></td><td></td>' if (!length $add);
	return $add;
}

138 139 140 141 142
# Count wml files in given directory
#
sub getwmlfiles
{
    my $lang = shift;
143 144
    my $dir = "$lang";
#    my $cutfrom = length ($config{'wmldir'})+length($lang)+2;
145
    my $count = 0;
146
    my $size = 0;
147
    my $is_english = ($lang eq "english")?1:0;
148
    my ( $file, $v );
149
    my @listfiles;
150
    my %altrev_info;
151

152 153 154 155
    if (! -d "$dir") {
      print "$0: can't find $dir! Skipping ...\n";
      return;
    }
156
    if ($is_english) {
157
        @listfiles = sort keys(%rev_info);
158
    } else {
159 160 161 162 163
	%altrev_info = $VCS->path_info($dir,
				       'recursive' => 1,
				       'match_pat' => $config{'wmlpat'},
				       'skip_pat'  => "template");
        @listfiles = sort keys(%altrev_info);
164
    }
165 166 167 168 169 170 171 172
#    print "cutfrom is $cutfrom\n";
#    print "Looking at @listfiles\n";
#    open (LIST, ">$config{'htmldir'}/$lang.list")
#	|| die "Can't open $config{'htmldir'}/$lang.list";
    foreach my $file (@listfiles) {
#	print LIST "$file\n";
#	$file = substr ($f, $cutfrom);
#	print "looking at $file\n";
173
	next if $transignore->is_global($file);
174
	$files{$file} = 1;
175
	$wmlfiles{$lang} .= " " . $file;
176
	my $transcheck = Webwml::TransCheck->new("$dir/$file");
177 178 179 180
	if ($transcheck->revision()) {
	    $transversion{"$lang/$file"} = $transcheck->revision();
	    $original{"$lang/$file"} ||= $transcheck->original();
	}
181
	if ($is_english) {
182
	    $version{"$lang/$file"} = $rev_info{"$file"}{'cmt_rev'};
183
	} else {
184
	    $version{"$lang/$file"} = $altrev_info{"$file"}{'cmt_rev'};
185
	    if (!$transcheck->revision()) {
186 187
	        $transcheckenglish = Webwml::TransCheck->new("english/$file");
		if (!$transcheckenglish->revision() and (-e "english/$file")) {
188
		    $transversion{"$lang/$file"} = $VCS->get_oldest_revision("english/$file");
189 190 191
		    $original{"$lang/$file"} = "english";
		} else {
		    $original{"english/$file"} = $lang;
192
		    $transversion{"english/$file"} = $VCS->get_oldest_revision("$lang/$file");
193
		}
194
	    }
195
	}
196
	if ($transcheck->maintainer()) {
197 198 199 200 201 202 203 204 205
	    # Escape HTML special characters to make the resulting page valid.
	    # This is needed for maintainers who use their e-mail address
	    # within angle brackets.
	    my %_escape_table = (
		'&' => '&amp;', '>' => '&gt;', '<' => '&lt;',
		q{"} => '&quot;', q{'} => '&#39;',
		q{`} => '&#96;', '{' => '&#123;',
		'}' => '&#125;'
	    );
206
	    $maintainer{"$lang/$file"} = $transcheck->maintainer();
207
	    $maintainer{"$lang/$file"} =~ s/([&><"'`{}])/$_escape_table{$1}/ge;
208
	}
209
	$count++;
210 211
	$sizes{$file} = (stat "".($original{"english/$file"}||"english")."/".$file)[7];
	$size += $sizes{$file};
212
    }
213
#    close LIST;
214 215
    $wmlfiles{$lang} .= " ";
    $wml{$lang} = $count;
216
    $wml_s{$lang} = $size;
217 218 219
    if ($config{verbose}) {
	print "  $lang: $count wml files, $size bytes\n";
    }
220
}
221 222 223 224 225

sub get_color
{
    my $percent = shift;

226 227
    if ($percent < 50) {
    	return sprintf ("#FF%02x00", (255/50) * $percent);
228
    } else {
229
	return sprintf ("#%02xFF00", (255/50) * (100 - $percent));
230 231 232
    }
}

233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
# Update the translation-check metadata header in a wml file
sub update_file_metadata
{
    my $file = shift;
    my $revision = shift;
    my $hash = shift;
    my $text = "";

    open (IN, "< $file") or die "Can't open $file for reading: $!\n";
    while (<IN>) {
	if (m/^#use wml::debian::translation-check/) {
	    s/(translation="?)($revision)("?)/$1$hash$3/;
	}
	$text .= $_;
    }
    close(IN);
    open(OUT, "> $file") or die "Can't open $file for writing: $!\n";
    print OUT $text;
    close OUT;
}

254 255
sub check_translation
{
256 257
    my ($translation, $version, $file, $orig_file) = @_;

258
    my ( @version_numbers, $major_number, $last_number );
259
#    print "  check_translation: looking at translation $translation, english version $version, file $file, orig_file $orig_file\n";
260

261
    if ( $version && $translation ) {
262 263 264
	# Here we compare the original version with the translated one and print
	# a note for the user if their first or last numbers are too far apart
	# From translation-check.wml
265
	my $version_diff = $VCS->count_changes($orig_file, $translation, $version);
266
	if (!defined $version_diff) {
267 268 269 270 271 272 273 274 275
	    print "check_translation: error from count_changes() for orig_file $orig_file, file $file\n";
	    if ($config{'repair'}) {
		# Replace the translation reference with the most
		# recent version of the original? Yes, they're all
		# either really old or files with only one commit...
		my $latest_rev_orig = $VCS->get_newest_revision($orig_file);
		print "  fixing: using rev $latest_rev_orig instead of $translation\n";
		update_file_metadata($file, $translation, $latest_rev_orig);
	    }
276 277 278 279 280 281 282 283
	} else {
	    if ($version_diff < 0) {
		return '<gettext domain="stats">Wrong translation version</gettext>';
	    } elsif ( $version_diff >= $max_versions ) {
		return '<gettext domain="stats">This translation is too out of date</gettext>';		
	    } elsif ( $version_diff >= $min_versions ) {
		return '<gettext domain="stats">The original is newer than this translation</gettext>';
	    }
284
	}
285
    } elsif ( !$version && $translation) {
286
	return '<gettext domain="stats">The original no longer exists</gettext>';
287 288 289 290
    }
    return "";
}

291
print "Collecting data:\n" if ($config{'verbose'});
292 293 294
if ($opt_l) {
  getwmlfiles ($opt_l);
  getwmlfiles ('english');
295
} else {
296
  foreach $lang (sort keys %langs) {
297
    getwmlfiles ($lang);
298
  }
299 300 301
}
print "\n" if ($config{'verbose'});

Denis Barbier's avatar
Denis Barbier committed
302 303 304 305 306 307 308
my @search_in;
if ($opt_l) {
  @search_in = ( 'english', $opt_l );
} else {
  @search_in = sort keys %langs;
}

309
# Compute stats about gettext files
Josip Rodin's avatar
Josip Rodin committed
310
print "Computing statistics in gettext files... " if ($config{'verbose'});
311 312
my ( %po_translated, %po_fuzzy, %po_untranslated, %po_total );
my ( %percent_po_t, %percent_po_u, %percent_po_f );
Denis Barbier's avatar
Denis Barbier committed
313 314
foreach $lang (@search_in) {
    next if $lang eq 'english';
315
    $po_translated{"total"}{$lang} = $po_fuzzy{"total"}{$lang} = $po_untranslated{"total"}{$lang} = 0;
316 317 318
    $percent_po_t{'total'}{$lang} = 0;
    $percent_po_f{'total'}{$lang} = 0;
    $percent_po_u{'total'}{$lang} = 100;
319 320
    if (! -d "$lang/po") {
      print "$0: can't find $lang/po! Skipping ...\n";
321 322
      next;
    }
323
    my @status = qx,LC_ALL=C make -C $lang/po stats 2>&1,;
Denis Barbier's avatar
Denis Barbier committed
324 325
    foreach $line (@status) {
        chomp $line;
326
        next if($line =~ /make: (Enter|Leav)ing directory/);
Denis Barbier's avatar
Denis Barbier committed
327 328 329 330 331
        ($domain = $line) =~ s/\..*//;
        $po_translated{$domain}{$lang} = ($line =~ /(\d+) translated/ ? $1 : "0");
        $po_fuzzy{$domain}{$lang} = ($line =~ /(\d+) fuzzy/ ? $1 : "0");
        $po_untranslated{$domain}{$lang} = ($line =~ /(\d+) untranslated/ ? $1 : "0");

332
        $po_total{$domain} = $po_translated{$domain}{$lang} + $po_fuzzy{$domain}{$lang} + $po_untranslated{$domain}{$lang};
333

334 335 336
        $po_translated{"total"}{$lang} += $po_translated{$domain}{$lang};
	$po_fuzzy{"total"}{$lang} += $po_fuzzy{$domain}{$lang};
	$po_untranslated{"total"}{$lang} += $po_untranslated{$domain}{$lang};
337

338 339 340 341 342 343 344
        if ($po_total{$domain} > 0) {
            $percent_po_t{$domain}{$lang} = int ($po_translated{$domain}{$lang}/$po_total{$domain} * 100 + .5);
            $percent_po_f{$domain}{$lang} = int ($po_fuzzy{$domain}{$lang}/$po_total{$domain} * 100 + .5);
            $percent_po_u{$domain}{$lang} = int ($po_untranslated{$domain}{$lang}/$po_total{$domain} * 100 + .5);
        } else {
            $percent_po_t{$domain}{$lang} = 0;
            $percent_po_f{$domain}{$lang} = 0;
345
            $percent_po_u{$domain}{$lang} = 0; # or 100 if po/ doesn't exist
346
        }
Denis Barbier's avatar
Denis Barbier committed
347
    }
348
    $po_total{"total"} = $po_translated{"total"}{$lang} + $po_fuzzy{"total"}{$lang} + $po_untranslated{"total"}{$lang};
349

350 351 352 353 354
    if ($po_total{'total'} > 0) {
	$percent_po_t{'total'}{$lang} = int ($po_translated{'total'}{$lang}/$po_total{'total'} * 100 + .5);
	$percent_po_f{'total'}{$lang} = int ($po_fuzzy{'total'}{$lang}/$po_total{'total'} * 100 + .5);
	$percent_po_u{'total'}{$lang} = int ($po_untranslated{'total'}{$lang}/$po_total{'total'} * 100 + .5);
    }
Denis Barbier's avatar
Denis Barbier committed
355
}
356
print "done.\n" if ($config{'verbose'});
Denis Barbier's avatar
Denis Barbier committed
357

358
# =============== Create HTML files ===============
359
mkdir ($config{'htmldir'}, 02775) if (! -d $config{'htmldir'});
360

361 362
# Read website hit statistics, if available
my %hits;
363
my $file_sorter = sub($$) { $_[0] cmp $_[1] };
364
if ($config{'hit_file'}) {
365 366 367 368 369 370 371 372 373
    printf("Retrieving hit data from [%s].\n", $config{'hit_file'}) if ($config{'verbose'});
    open( my $fh, '<', $config{'hit_file'} );
    local $/;
    my $json = <$fh>;
    close $fh;
    if ($json) {
        my $perl = JSON::from_json($json, {utf8 => 1});
        foreach my $e (@{$perl}) {
            my ($count, $url) = @$e;
374 375 376 377 378 379 380 381 382 383 384 385 386
            last if $count < 3; # URLS with 2 or 1 hits are most likely mistakes; let's not waste RAM on them
            $hits{substr($url, 1)} = $count;
        }
    }
    if (%hits) {
        $file_sorter = sub($$) {
            my ($a, $b) = @_;
            $a =~ s/\.wml$//o;
            $b =~ s/\.wml$//o;
            $hits{$b} <=> $hits{$a}
        };
    } else {
        print "Tables will be sorted alphabetically.\n" if ($config{'verbose'});
387 388 389 390 391 392
    }
} else {
    print "No hit file specified. Tables will be sorted alphabetically.\n" if ($config{'verbose'});
}

my @filenames = sort $file_sorter keys %files;
393
my $nfiles = scalar @filenames;
394
$nsize += $sizes{$_} foreach (@filenames);
395

396
# 'u' == 'unidiff', 'h' == 'colored diff'
397 398 399 400 401 402 403 404 405 406
my $firstdifftype;
my $seconddifftype;
if ($config{'difftype'} eq 'u') {
    $firstdifftype = 'u';
    $seconddifftype = 'h';
} else {
    $firstdifftype = 'h';
    $seconddifftype = 'u';
}

407
sub vcs_log_url {
408
    my ($path, $rev) = @_;
409

410
    if ($VCSHOST =~ m/salsa/) {
411
	return "$VCSBASE/commits/$rev/$path";
412 413 414
    } else {
	die "Unknown/unsupported VCSHOST $VCSHOST - ABORT\n";
    }
415 416
}

417
sub vcs_diff_url {
418 419
    my ( $path, $r1, $r2, $diff_format ) = @_;

420
    if ($VCSHOST =~ m/salsa/) {
421
	return "$VCSBASE/compare?from=$r1&amp;to=$r2";
422 423 424
    } else {
	die "Unknown/unsupported VCSHOST $VCSHOST - ABORT\n";
    }
425 426
}

427
sub vcs_view_url {
428 429
    my ($path) = @_;

430
    if ($VCSHOST =~ m/salsa/) {
431 432 433 434
	return "$VCSBASE/blob/master/$path";
    } else {
	die "Unknown/unsupported VCSHOST $VCSHOST - ABORT\n";
    }
435 436
}

437
sub vcs_raw_url {
438 439
    my ($path) = @_;

440
    if ($VCSHOST =~ m/salsa/) {
441 442 443 444
	return "$VCSBASE/raw/master/$path";
    } else {
	die "Unknown/unsupported VCSHOST $VCSHOST - ABORT\n";
    }
445 446
}

447 448 449 450 451 452 453 454 455 456
# Return a shortened version string to make things less unwieldy
sub short {
    my $in = shift;
    if ($VCSHOST =~ m/salsa/) {
	return substr $in, 0, 12; # 12 is a common length people use for git
    } else {
	return $in;
    }
}

457
print "Creating files: " if ($config{'verbose'});
458
foreach $lang (@search_in) {
459 460
    my @processed_langs = ($langs{$lang});
    @processed_langs = ("zh-cn", "zh-tw") if $langs{$lang} eq "zh";
461
    foreach $l (sort @processed_langs) {
462
        print "$l.wml " if ($config{'verbose'});
463
        $t_body = $u_body = $ui_body = $un_body = $uu_body = $o_body = "";
Thomas Huriaux's avatar
Thomas Huriaux committed
464
        $translated{$lang} = $outdated{$lang} = $untranslated{$lang} = 0;
Denis Barbier's avatar
Denis Barbier committed
465 466 467 468

        # get stats about files
        foreach $file (@filenames) {
            next if ($file eq "");
469
            (my $base = $file) =~ s/\.wml$//;
470
            my $hits = exists $hits{$base} ? $hits{$base}.' <gettext domain="stats">hits</gettext>' : '<gettext domain="stats">hit count N/A</gettext>';
471 472 473 474
	    my $todo = '<td></td><td></td><td></td>';
	    $todo = linklist($file, $lang) if defined $status_db{$lang};
	    # Translated pages or already WIP in translation list
            if ((index ($wmlfiles{$lang}, " $file ") >= 0) or (($todo ne '<td></td><td></td><td></td>') and ($transversion{"$lang/$file"} ne $version{"$orig/$file"}))) {
Denis Barbier's avatar
Denis Barbier committed
475
                $translated{$lang}++;
476
		$translated_s{$lang} += $sizes{$file};
Denis Barbier's avatar
Denis Barbier committed
477 478
                $orig = $original{"$lang/$file"} || "english";
                # Outdated translations
479
                $msg = check_translation ($transversion{"$lang/$file"}, $version{"$orig/$file"}, "$lang/$file", "$orig/$file");
480
                if (length ($msg) or (($todo ne '<td></td><td></td><td></td>') and ($transversion{"$lang/$file"} ne $version{"$orig/$file"}))) {
Denis Barbier's avatar
Denis Barbier committed
481
                    $o_body .= "<tr>";
482
                    if (($file !~ /\.wml$/)
Denis Barbier's avatar
Denis Barbier committed
483 484 485
                        || ($file eq "devel/wnpp/wnpp.wml")) {
                        $o_body .= sprintf "<td>%s</td>", $file;
                    } else {
486
                        $o_body .= sprintf "<td><a title=\"%s\" href=\"$opt_b/%s\">%s</a></td>", $hits, $base, $base;
Denis Barbier's avatar
Denis Barbier committed
487
                    }
488 489 490
		    my $stattd = sprintf '<td style=\'font-family: monospace\' title=\'<gettext domain="stats">Click to fetch diffstat data</gettext>\' onClick="setDiffstat(\'%s\', \'%s\', \'%s\', this)">+/-</td>', $file, $transversion{"$lang/$file"}, $version{"$orig/$file"};
		    my $statspan = sprintf '(<span style=\'font-family: monospace\' title=\'<gettext domain="stats">Click to fetch diffstat data</gettext>\' onClick="setDiffstat(\'%s\', \'%s\', \'%s\', this)">+/-</span>)', $file, $transversion{"$lang/$file"}, $version{"$orig/$file"};
		  if (!defined $status_db{$lang}) {
Denis Barbier's avatar
Denis Barbier committed
491
                    $o_body .= sprintf "<td>%s</td>", $msg;
492 493
                    $o_body .= $stattd;
	          }
494
		    if ($msg eq '<gettext domain="stats">Wrong translation version</gettext>' || $msg eq '<gettext domain="stats">The original no longer exists</gettext>') {
495 496 497
		      if (defined $status_db{$lang}) {
			$o_body .= sprintf "<td>%d (%.2f&nbsp;&permil;)</td>", $sizes{$file}, $sizes{$file}/$nsize * 1000;
		      } else {
498
		        $o_body .= "<td></td><td></td>";
499
		      }
500
		    } else {
501 502 503 504 505 506 507
			if (defined $status_db{$lang}) {
			    if ($transversion{"$lang/$file"} ne ''){
				$o_body .= sprintf "<td>git diff %s..%s -- %s</td>",
				    short($transversion{"$lang/$file"}), short($version{"$orig/$file"}), "$orig/$file";
			    } else {
				$o_body .= sprintf "<td>%d (%.2f&nbsp;&permil;)</td>", $sizes{$file}, $sizes{$file}/$nsize * 1000;
			    }
508
			} else {
509 510
			    $o_body .= sprintf "<td>git diff %s..%s -- %s</td>",
				short($transversion{"$lang/$file"}), short($version{"$orig/$file"}), "$orig/$file";
511
			}
512
		  }
513
		    $o_body .= sprintf "<td><a title=\"%s\" href=\"%s\">[L]</a></td>", $msg, vcs_log_url("$orig/$file", $version{"$orig/$file"});
514 515
                    $o_body .= sprintf "<td><a href=\"%s\">[V]</a>\&nbsp;", vcs_view_url("$lang/$file");
                    $o_body .= sprintf "<a href=\"%s\">[F]</a></td>", vcs_raw_url("$lang/$file");
Denis Barbier's avatar
Denis Barbier committed
516
                    $o_body .= sprintf "<td align=center>%s</td>", $maintainer{"$lang/$file"} || "";
517
		    $o_body .= $todo if (defined $status_db{$lang});
Denis Barbier's avatar
Denis Barbier committed
518 519
                    $o_body .= "</tr>\n";
                    $outdated{$lang}++;
520
		    $outdated_s{$lang} += $sizes{$file};
Denis Barbier's avatar
Denis Barbier committed
521 522
                # Up-to-date translations
                } else {
523
                    if (($file !~ /\.wml$/)
Denis Barbier's avatar
Denis Barbier committed
524
                        || ($file eq "devel/wnpp/wnpp.wml")) {
525
                        $t_body .= sprintf "<li>%s</li>\n", $file;
Denis Barbier's avatar
Denis Barbier committed
526
                    } else {
527
                        $t_body .= sprintf "<li><a title=\"%s\" href=\"$opt_b/%s.%s.html\">%s</a></li>\n", $hits, $base, $l, $base;
Denis Barbier's avatar
Denis Barbier committed
528 529 530 531 532
                    }
                }
            }
            # Untranslated pages
            else {
533
	        my $u_tmp;
Denis Barbier's avatar
Denis Barbier committed
534 535
                if (($file !~ /\.wml$/)
                    || ($file eq "devel/wnpp/wnpp.wml")) {
536
                    $u_tmp = sprintf "<tr><td>%s</td><td>&nbsp;</td></tr>\n", $file;
Denis Barbier's avatar
Denis Barbier committed
537
                } else {
538
                    $u_tmp = sprintf "<tr><td><a title=\"%s\" href=\"$opt_b/%s\">%s&nbsp;&nbsp;(%s)</a></td><td align=\"right\">%d</td><td>(%.2f&nbsp;&permil;)</td></tr>\n", $hits, $base, $base, $version{"$orig/$file"}, $sizes{$file}, $sizes{$file}/$nsize * 1000;
Denis Barbier's avatar
Denis Barbier committed
539
                }
540
		if (($file =~ /international\//) &&
541 542
		    ($file !~ /international\/index.wml$/) &&
		    ($file !~ /international\/l10n\//)) {
543 544 545 546
		    $ui_body .=$u_tmp;
		} elsif ((($file =~ /(News|events|security|vote)\/[0-9]{4}\//) &&
		          ($file !~ /index.wml$/)) ||
		         ($file =~ /(News\/weekly\/[0-9]{4}\/|security\/undated)/)) {
547 548 549 550 551 552 553
		    $un_body .= $u_tmp;
		} elsif (($file =~ /(consultants|users\/(com|edu|gov|org))\//) &&
		         ($file !~ /index.wml$/)) {
		    $uu_body .=$u_tmp;
		} else {
		    $u_body .= $u_tmp;
		}
Denis Barbier's avatar
Denis Barbier committed
554
                $untranslated{$lang}++;
555
		$untranslated_s{$lang} += $sizes{$file};
Denis Barbier's avatar
Denis Barbier committed
556 557
            }
        }
558 559


Denis Barbier's avatar
Denis Barbier committed
560 561 562 563
        # this is where we discard the files that the translation directory contains
        # but which don't exist in the English directory
        #   print "extra files: ".$wml{$lang}-$translated{$lang}."\n";
        $wml{$lang} = $translated{$lang};
564
	$wml_s{$lang} = $translated_s{$lang};
Denis Barbier's avatar
Denis Barbier committed
565
        $translated{$lang} = $translated{$lang} - $outdated{$lang};
566
	$translated_s{$lang} = $translated_s{$lang} - $outdated_s{$lang};
567

Denis Barbier's avatar
Denis Barbier committed
568
        if ($nfiles > 0) {
569
            $percent_a{$lang} = $wml{$lang}/$nfiles * 100;
Denis Barbier's avatar
Denis Barbier committed
570 571
        } else {
            $percent_a{$lang} = 0;
572 573 574 575
        }
        if ($nsize > 0) {
            $percent_as{$lang} = $wml_s{$lang}/$nsize * 100;
        } else {
576
	    $percent_as{$lang} = 0;
Denis Barbier's avatar
Denis Barbier committed
577 578
        }
        if ($wml{$lang} > 0) {
579
            $percent_t{$lang} = $translated{$lang}/$wml{$lang} * 100;
Denis Barbier's avatar
Denis Barbier committed
580 581
        } else {
            $percent_t{$lang} = 0;
582 583 584 585
        }
        if ($wml_s{$lang} > 0) {
            $percent_ts{$lang} = $translated_s{$lang}/$wml_s{$lang} * 100;
        } else {
586
	    $percent_ts{$lang} = 0;
Denis Barbier's avatar
Denis Barbier committed
587 588
        }
        $percent_o{$lang} = 100 - $percent_t{$lang};
589
	$percent_os{$lang} = 100 - $percent_ts{$lang};
Denis Barbier's avatar
Denis Barbier committed
590
        $percent_u{$lang} = 100 - $percent_a{$lang};
591
	$percent_us{$lang} = 100 - $percent_as{$lang};
592

593
        if (open (HTML, ">$config{'htmldir'}/$l.wml")) {
594
	    printf HTML "#use wml::debian::template title=\"<:=\$trans{\$CUR_ISO_LANG}{%s}:>\"\n", $lang;
595
	    print HTML "#use wml::debian::toc\n";
596
        printf HTML qq|<define-tag transstatslink><a href="%s">webwml-stattrans</a></define-tag>\n|,
597
            vcs_view_url('stattrans.pl');
598
        print HTML "<define-tag createdwith><address>\n";
Laura Arjona Reina's avatar
Laura Arjona Reina committed
599
        print HTML '<gettext domain="stats">Created with <transstatslink></gettext>';
600
        print HTML "</address></define-tag>\n";
601
            print HTML "<script src=\"diffstat.js\" type=\"text/javascript\"></script>\n\n";
Denis Barbier's avatar
Denis Barbier committed
602
            $color = get_color ($percent_a{$lang});
603

604
            printf HTML '<table summary="<gettext domain="stats">Translation summary for</gettext> <:=$trans{$CUR_ISO_LANG}{'.$lang.'} :>" style="background-color: %s; width: 100%; font-weight: bold; margin: 0; text-align: center;">'."\n", $color;
605
            print HTML "<colgroup span=\"4\" width=\"25%\"></colgroup>\n";
606

607
            print HTML '<tr><th><gettext domain="stats">Translated</gettext></th><th><gettext domain="stats">Up to date</gettext></th><th><gettext domain="stats">Outdated</gettext></th><th><gettext domain="stats">Not translated</gettext></th></tr>'."\n<tr>\n";
608 609 610 611
            printf HTML '<td>%d <gettext domain="stats">files</gettext> (%.1f%%)</td>', $wml{$lang}, $percent_a{$lang};
            printf HTML '<td>%d <gettext domain="stats">files</gettext> (%.1f%%)</td>', $translated{$lang}, $percent_t{$lang};
            printf HTML '<td>%d <gettext domain="stats">files</gettext> (%.1f%%)</td>', $outdated{$lang}, $percent_o{$lang};
            printf HTML '<td>%d <gettext domain="stats">files</gettext> (%.1f%%)</td>', $untranslated{$lang}, $percent_u{$lang};
Denis Barbier's avatar
Denis Barbier committed
612
            print HTML "</tr>\n";
613
	    print HTML "<tr>\n";
614 615 616 617
	    printf HTML '<td>%d <gettext domain="stats">bytes</gettext> (%.1f%%)</td>', $wml_s{$lang}, $percent_as{$lang};
	    printf HTML '<td>%d <gettext domain="stats">bytes</gettext> (%.1f%%)</td>', $translated_s{$lang}, $percent_ts{$lang};
	    printf HTML '<td>%d <gettext domain="stats">bytes</gettext> (%.1f%%)</td>', $outdated_s{$lang}, $percent_os{$lang};
	    printf HTML '<td>%d <gettext domain="stats">bytes</gettext> (%.1f%%)</td>', $nsize-$wml_s{$lang}, $percent_us{$lang};
618
	    print HTML "</tr>\n";
Denis Barbier's avatar
Denis Barbier committed
619
            print HTML "</table>\n";
620

Denis Barbier's avatar
Denis Barbier committed
621
            # Make the table of content
622
	    print HTML "<toc-display/>\n";
623
            if (%hits) {
624 625
                print HTML '<p><gettext domain="stats">Note: the lists of pages are sorted by popularity. Hover over the page name to see the number of hits.</gettext>';
                print HTML "</p>\n";
626 627
            }

Denis Barbier's avatar
Denis Barbier committed
628 629
            # outputs the content
            if ($o_body) {
630
                print HTML '<toc-add-entry name="outdated"><gettext domain="stats">Outdated translations</gettext></toc-add-entry>'."\n";
631
                print HTML "<table summary=\"Outdated translations\" border=0 cellpadding=1 cellspacing=1>\n";
632
                print HTML '<tr><th><gettext domain="stats">File</gettext></th>'."\n";
633 634 635
	      if (defined $status_db{$lang}) {
		print HTML '<th><gettext domain="stats">Diff</gettext></th>';
	      } else {
636
		print HTML '<th><gettext domain="stats">Comment</gettext></th>'."\n";
637
		print HTML '<th><gettext domain="stats">Diffstat</gettext></th>'."\n";
638
		print HTML '<th><gettext domain="stats">Git command line</gettext></th>';
639
	      }
640 641 642
                print HTML '<th><gettext domain="stats">Log</gettext></th>';
                print HTML '<th><gettext domain="stats">Translation</gettext></th>';
                print HTML '<th><gettext domain="stats">Maintainer</gettext></th>';
643 644 645 646 647
	      if (defined $status_db{$lang}) {
		print HTML '<th><gettext domain="stats">Status</gettext></th>';
		print HTML '<th><gettext domain="stats">Translator</gettext></th>';
		print HTML '<th><gettext domain="stats">Date</gettext></th>';
	      }
Denis Barbier's avatar
Denis Barbier committed
648 649 650 651 652
                print HTML "</tr>\n";
                print HTML $o_body;
                print HTML "</table>\n";
            }
            if ($u_body) {
653 654
                print HTML '<toc-add-entry name="untranslated"><gettext domain="stats">General pages not translated</gettext></toc-add-entry>'."\n";
                print HTML '<table summary="<gettext domain="stats">Untranslated general pages</gettext>">'."\n";
Denis Barbier's avatar
Denis Barbier committed
655
                print HTML $u_body;
656
                print HTML "</table>\n";
Denis Barbier's avatar
Denis Barbier committed
657
            }
658
            if ($un_body) {
659 660
                print HTML '<toc-add-entry name="untranslated-news"><gettext domain="stats">News items not translated</gettext></toc-add-entry>'."\n";
                print HTML '<table summary="<gettext domain="stats">Untranslated news items</gettext>">'."\n";
661
                print HTML $un_body;
662
                print HTML "</table>\n";
663 664
            }
            if ($uu_body) {
665 666
                print HTML '<toc-add-entry name="untranslated-user"><gettext domain="stats">Consultant/user pages not translated</gettext></toc-add-entry>'."\n";
                print HTML '<table summary="<gettext domain="stats">Untranslated consultant/user pages</gettext>">'."\n";
667
                print HTML $uu_body;
668
                print HTML "</table>\n";
669
            }
670
            if ($ui_body) {
671 672
                print HTML '<toc-add-entry name="untranslated-l10n"><gettext domain="stats">International pages not translated</gettext></toc-add-entry>'."\n";
                print HTML '<table summary="<gettext domain="stats">Untranslated international pages</gettext>">'."\n";
673 674 675
                print HTML $ui_body;
                print HTML "</table>\n";
            }
Denis Barbier's avatar
Denis Barbier committed
676
            if ($t_body) {
677
                print HTML '<toc-add-entry name="uptodate"><gettext domain="stats">Translated pages (up-to-date)</gettext></toc-add-entry>'."\n";
678
                print HTML "<ul class=\"discless\">\n";
Denis Barbier's avatar
Denis Barbier committed
679
                print HTML $t_body;
680
                print HTML "</ul>\n";
Denis Barbier's avatar
Denis Barbier committed
681 682 683
            }
            # outputs the gettext stats
            if ($lang ne 'english') {
684 685 686 687 688
                print HTML '<toc-add-entry name="gettext"><gettext domain="stats">Translated templates (PO files)</gettext></toc-add-entry>'."\n";
                print HTML '<table summary="<gettext domain="stats">PO Translation Statistics</gettext>" width="100%">'."\n";
		print HTML '<tr><th><gettext domain="stats">File</gettext></th>'."\n";
		print HTML '<th><gettext domain="stats">Up to date</gettext></th>'."\n";
		print HTML '<th><gettext domain="stats">Fuzzy</gettext></th>'."\n";
689 690
		print HTML '<th><gettext domain="stats">Untranslated</gettext></th>'."\n";
		print HTML '<th><gettext domain="stats">Total</gettext></th></tr>'."\n";
Denis Barbier's avatar
Denis Barbier committed
691 692 693
                foreach my $domain (sort keys %po_total) {
                    next if $domain eq 'total';
                    print HTML "<tr>";
694

Denis Barbier's avatar
Denis Barbier committed
695 696 697
                    $color_t = get_color ($percent_po_t{$domain}{$lang});
                    $color_f = get_color (100 - $percent_po_f{$domain}{$lang});
                    $color_u = get_color (100 - $percent_po_u{$domain}{$lang});
698

Denis Barbier's avatar
Denis Barbier committed
699
                    print HTML "<td>$domain.$langs{$lang}.po</td>";
700 701 702
                    printf HTML "<td style=\"background-color: %s\" align=right>%d (%s%%)</td>", $color_t, $po_translated{$domain}{$lang},   $percent_po_t{$domain}{$lang};
                    printf HTML "<td style=\"background-color: %s\" align=right>%d (%s%%)</td>", $color_f, $po_fuzzy{$domain}{$lang},        $percent_po_f{$domain}{$lang};
                    printf HTML "<td style=\"background-color: %s\" align=right>%d (%s%%)</td>", $color_u, $po_untranslated{$domain}{$lang}, $percent_po_u{$domain}{$lang};
Denis Barbier's avatar
Denis Barbier committed
703 704 705
                    printf HTML "<td align=right>%d</td>", $po_total{$domain};
                    print HTML "</tr>\n";
                }
706 707
                print HTML "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
		print HTML '<tr><th><gettext domain="stats">Total:</gettext></th>';
Denis Barbier's avatar
Denis Barbier committed
708 709 710
                $color_t = get_color ($percent_po_t{'total'}{$lang});
                $color_f = get_color (100 - $percent_po_f{'total'}{$lang});
                $color_u = get_color (100 - $percent_po_u{'total'}{$lang});
711 712 713
                printf HTML "<td style=\"background-color: %s\" align=right>%d (%d%%)</td>", $color_t, $po_translated{'total'}{$lang}, $percent_po_t{'total'}{$lang};
                printf HTML "<td style=\"background-color: %s\" align=right>%d (%d%%)</td>", $color_f, $po_fuzzy{'total'}{$lang}, $percent_po_f{'total'}{$lang};
                printf HTML "<td style=\"background-color: %s\" align=right>%d (%d%%)</td>", $color_u, $po_untranslated{'total'}{$lang}, $percent_po_u{'total'}{$lang};
Denis Barbier's avatar
Denis Barbier committed
714 715
                printf HTML "<td align=right>%d</td>", $po_total{'total'};
                print HTML "</tr>\n";
716
                print HTML "</table>\n";
Denis Barbier's avatar
Denis Barbier committed
717
            }
718

719
            print HTML "<createdwith/>\n";
Denis Barbier's avatar
Denis Barbier committed
720
            close (HTML);
721 722
        } else {
            print "Can't open $config{'htmldir'}/$l.wml\n";
Denis Barbier's avatar
Denis Barbier committed
723
        }
724
    }
725
}
726
print "\n" if ($config{'verbose'});
727 728

# =============== Creating index.html ===============
729 730 731 732 733
print "Creating index.wml... " if ($config{'verbose'});

open (HTMLI, ">$config{'htmldir'}/index.wml")
    || die "Can't open $config{'htmldir'}/index.wml";

734
print HTMLI "#use wml::debian::stats_tags\n";
735
printf HTMLI "#use wml::debian::template title=\"%s\"\n\n", $config{'title'};
736
printf HTMLI qq|<define-tag transstatslink><a href="%s">webwml-stattrans</a></define-tag>\n|,
737
       vcs_view_url('stattrans.pl');
738
print HTMLI "<define-tag createdwith><address>\n";
Laura Arjona Reina's avatar
Laura Arjona Reina committed
739
print HTMLI '<gettext domain="stats">Created with <transstatslink></gettext>';
740
print HTMLI "</address></define-tag>\n";
741 742
print HTMLI '<h2><gettext domain="stats">Translated web pages</gettext></h2>'."\n";
printf HTMLI "<p><stats_pages %d></p>\n",($wml{'english'}+$untranslated{'english'});
743

744
print HTMLI '<table summary="<gettext domain="stats">Translation Statistics by Page Count</gettext>" class="stattrans">'."\n";
745 746 747 748 749 750 751 752 753 754 755 756 757 758
print HTMLI "<colgroup width=\"20%\">\n";
print HTMLI "<col>\n";
print HTMLI "</colgroup>";
print HTMLI "<colgroup width=\"10%\">\n";
print HTMLI "<col width=\"10%\">\n";
print HTMLI "<col width=\"10%\">\n";
print HTMLI "<col width=\"10%\">\n";
print HTMLI "<col width=\"10%\">\n";
print HTMLI "<col width=\"10%\">\n";
print HTMLI "<col width=\"10%\">\n";
print HTMLI "<col width=\"10%\">\n";
print HTMLI "<col width=\"10%\">\n";
print HTMLI "</colgroup>";
print HTMLI "<thead>";
759 760 761 762 763
print HTMLI '<tr><th><gettext domain="stats">Language</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Translations</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Up to date</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Outdated</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Not translated</gettext></th></tr>'."\n";
764 765
print HTMLI "</thead>";
print HTMLI "<tbody>";
766
foreach $lang (@search_in) {
767 768 769
    my @processed_langs = ($langs{$lang});
    @processed_langs = ("zh-cn", "zh-tw") if $langs{$lang} eq "zh";
    foreach $l (@processed_langs) {
770 771 772 773 774
        $color_a = get_color ($percent_a{$lang});
        $color_t = get_color ($percent_t{$lang});
        $color_o = get_color (100 - $percent_o{$lang});
        $color_u = get_color (100 - $percent_u{$lang});

775
        print HTMLI "<tr>";
776
        printf HTMLI "<th><a href=\"%s\"><:=\$trans{\$CUR_ISO_LANG}{%s} :></a> (%s)</th>", $l, $lang, $l;
777 778 779 780
        printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_a, $wml{$lang},          $percent_a{$lang};
        printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</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};
        printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_u, $untranslated{$lang}, $percent_u{$lang};
781
        print HTMLI "</tr>\n";
782
    }
783
}
784 785 786
print HTMLI "</tbody>";
print HTMLI "</table>\n";

787 788
print HTMLI '<h2><gettext domain="stats">Translated web pages (by size)</gettext></h2>'."\n";
printf HTMLI "<p><stats_bytes %d></p>\n",($wml_s{'english'}+$untranslated_s{'english'});
789

790
print HTMLI '<table summary="<gettext domain="stats">Translation Statistics by Page Size</gettext>" class="stattrans">'."\n";
791 792 793 794 795 796 797 798 799 800 801 802 803 804
print HTMLI "<colgroup span=\"1\">\n";
print HTMLI "<col width=\"20%\">\n";
print HTMLI "</colgroup>";
print HTMLI "<colgroup span=\"8\">\n";
print HTMLI "<col width=\"13%\">\n";
print HTMLI "<col width=\"7%\">\n";
print HTMLI "<col width=\"13%\">\n";
print HTMLI "<col width=\"7%\">\n";
print HTMLI "<col width=\"13%\">\n";
print HTMLI "<col width=\"7%\">\n";
print HTMLI "<col width=\"13%\">\n";
print HTMLI "<col width=\"7%\">\n";
print HTMLI "</colgroup>";
print HTMLI "<thead>";
805 806 807 808 809
print HTMLI '<tr><th><gettext domain="stats">Language</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Translations</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Up to date</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Outdated</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Not translated</gettext></th></tr>'."\n";
810 811
print HTMLI "</thead>";
print HTMLI "<tbody>";
812 813 814 815 816 817 818 819 820 821

foreach $lang (@search_in) {
    my @processed_langs = ($langs{$lang});
    @processed_langs = ("zh-cn", "zh-tw") if $langs{$lang} eq "zh";
    foreach $l (@processed_langs) {
	$color_a = get_color ($percent_a{$lang});
	$color_t = get_color ($percent_t{$lang});
	$color_o = get_color (100 - $percent_o{$lang});
	$color_u = get_color (100 - $percent_u{$lang});

822
	print HTMLI "<tr>";
823
	printf HTMLI "<th><a href=\"%s\"><:=\$trans{\$CUR_ISO_LANG}{%s} :></a> (%s)</th>", $l, $lang, $l;
824 825 826 827
	printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_a, $wml_s{$lang},                   $percent_as{$lang};
	printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_t, $translated_s{$lang},            $percent_ts{$lang};
	printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%.1f%%)</td>", $color_o, $outdated_s{$lang},              $percent_os{$lang};
	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};
828
	print HTMLI "</tr>\n";
829 830
    }
}
831 832 833
print HTMLI "</tbody>";
print HTMLI "</table>\n";

834 835 836
print HTMLI '<h2><gettext domain="stats">Translated templates (PO files)</gettext></h2>'."\n";
printf HTMLI "<p><stats_strings %d></p>\n",$po_total{'total'};

837
print HTMLI '<table summary="<gettext domain="stats">PO Translation Statistics</gettext>" class="stattrans">'."\n";
838 839 840 841 842 843 844 845 846 847 848
print HTMLI "<colgroup span=\"1\"width=\"28%\">\n";
print HTMLI "</colgroup>";
print HTMLI "<colgroup span=\"6\" width=\"12%\">\n";
print HTMLI "<col width=\"12%\">\n";
print HTMLI "<col width=\"12%\">\n";
print HTMLI "<col width=\"12%\">\n";
print HTMLI "<col width=\"12%\">\n";
print HTMLI "<col width=\"12%\">\n";
print HTMLI "<col width=\"12%\">\n";
print HTMLI "</colgroup>";
print HTMLI "<thead>";
849 850 851 852
print HTMLI '<tr><th><gettext domain="stats">Language</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Up to date</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Fuzzy</gettext></th>'."\n";
print HTMLI '<th colspan="2"><gettext domain="stats">Not translated</gettext></th></tr>'."\n";
853 854
print HTMLI "</thead>";
print HTMLI "<tbody>";
Denis Barbier's avatar
Denis Barbier committed
855 856
foreach $lang (@search_in) {
    next if $lang eq 'english';
857 858 859
    my @processed_langs = ($langs{$lang});
    @processed_langs = ("zh-cn", "zh-tw") if $langs{$lang} eq "zh";
    foreach $l (@processed_langs) {
860
        print HTMLI "<tr>";
861
        printf HTMLI "<th><a href=\"%s#gettext\"><:=\$trans{\$CUR_ISO_LANG}{%s} :></a> (%s)</th>", $l, $lang, $l;
862 863 864
        $color_t = get_color ($percent_po_t{'total'}{$lang});
        $color_f = get_color (100 - $percent_po_f{'total'}{$lang});
        $color_u = get_color (100 - $percent_po_u{'total'}{$lang});
865 866 867
        printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%d%%)</td>", $color_t, $po_translated{'total'}{$lang},   $percent_po_t{'total'}{$lang};
        printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%d%%)</td>", $color_f, $po_fuzzy{'total'}{$lang},        $percent_po_f{'total'}{$lang};
        printf HTMLI "<td style=\"background-color: %s\">%d</td><td>(%d%%)</td>", $color_u, $po_untranslated{'total'}{$lang}, $percent_po_u{'total'}{$lang};
868
        print HTMLI "</tr>\n";
869
    }
Denis Barbier's avatar
Denis Barbier committed
870
}
871

872 873
print HTMLI "</tbody>";
print HTMLI "</table>\n";
Denis Barbier's avatar
Denis Barbier committed
874

875
print HTMLI "<createdwith/>\n";
876
close (HTMLI);
877

878
print "done.\n" if ($config{'verbose'});
879 880 881 882 883 884 885

# Note:
#   Translated pages on ll.html may be higher than in index.html.
#   This is due to the fact that some english pages were removed.

# printf "%s\n", join ("\n", keys %version);
# printf "%s - %s\n", $version{'german/devel/index'}, $version{'english/devel/index'};