From 40b28c6f529f7771c6e1e7d8acd776037c369e24 Mon Sep 17 00:00:00 2001 From: Nicolas Bertolissio Date: Sun, 11 Sep 2005 23:00:50 +0000 Subject: add stats on bytes to be translated (Closes: #256891) CVS version numbers stattrans.pl: 1.69 -> 1.70 --- stattrans.pl | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 80 insertions(+), 15 deletions(-) (limited to 'stattrans.pl') diff --git a/stattrans.pl b/stattrans.pl index b50ee8f8164..dc1acde7a02 100755 --- a/stattrans.pl +++ b/stattrans.pl @@ -88,7 +88,20 @@ my %original; my %transversion; my %version; my %files; +my %sizes; + sub format3($) { + $_ = sprintf("%d", shift); + $_ = "  $_" if length($_) < 2; + $_ = " $_" if length($_) < 3; + $_; + } + sub format5($) { + $_ = sprintf("%.1f", shift); + $_ = "  $_" if length($_) < 4; + $_ = " $_" if length($_) < 5; + $_; + } # Count wml files in given directory # sub getwmlfiles @@ -97,6 +110,7 @@ sub getwmlfiles my $dir = "$config{'wmldir'}/$lang"; my $cutfrom = length ($config{'wmldir'})+length($lang)+2; my $count = 0; + my $size = 0; my $is_english = ($lang eq "english")?1:0; my ( $file, $v ); my @listfiles; @@ -139,9 +153,12 @@ sub getwmlfiles $maintainer{"$lang/$file"} = $transcheck->maintainer(); } $count++; + $sizes{$file} = (stat "".($original{"english/$file"}||"english")."/".$file)[7]; + $size += $sizes{$file}; } $wmlfiles{$lang} .= " "; $wml{$lang} = $count; + $wml_s{$lang} = $size; } sub get_color @@ -261,6 +278,7 @@ mkdir ($config{'htmldir'}, 02775) if (! -d $config{'htmldir'}); my @filenames = sort keys %files; my $nfiles = scalar @filenames; +$nsize += $sizes{$_} foreach (@filenames); print "Creating files: " if ($config{'verbose'}); foreach $lang (@search_in) { @@ -278,6 +296,7 @@ foreach $lang (@search_in) { # Translated pages if (index ($wmlfiles{$lang}, " $file ") >= 0) { $translated{$lang}++; + $translated_s{$lang} += $sizes{$file}; $orig = $original{"$lang/$file"} || "english"; # Outdated translations $msg = check_translation ($transversion{"$lang/$file"}, $version{"$orig/$file"}, "$lang/$file"); @@ -302,6 +321,7 @@ foreach $lang (@search_in) { $o_body .= sprintf "%s", $maintainer{"$lang/$file"} || ""; $o_body .= "\n"; $outdated{$lang}++; + $outdated_s{$lang} += $sizes{$file}; # Up-to-date translations } else { if (($file !~ /\.wml$/) @@ -317,12 +337,13 @@ foreach $lang (@search_in) { else { if (($file !~ /\.wml$/) || ($file eq "devel/wnpp/wnpp.wml")) { - $u_body .= sprintf "%s
\n", $file; + $u_body .= sprintf "%s \n", $file; } else { (my $base = $file) =~ s/\.wml$//; - $u_body .= sprintf "%s
\n", $base, $base; + $u_body .= sprintf "%s%d(%.2f ‰)\n", $base, $base, $sizes{$file}, int($sizes{$file}/$nsize * 100000 + .5) / 100; } $untranslated{$lang}++; + $untranslated_s{$lang} += $sizes{$file}; } } @@ -331,20 +352,28 @@ foreach $lang (@search_in) { # but which don't exist in the English directory # print "extra files: ".$wml{$lang}-$translated{$lang}."\n"; $wml{$lang} = $translated{$lang}; + $wml_s{$lang} = $translated_s{$lang}; $translated{$lang} = $translated{$lang} - $outdated{$lang}; + $translated_s{$lang} = $translated_s{$lang} - $outdated_s{$lang}; if ($nfiles > 0) { $percent_a{$lang} = int ($wml{$lang}/$nfiles * 100 + .5); + $percent_as{$lang} = (int ($wml_s{$lang}/$nsize * 1000 + .5))/10; } else { $percent_a{$lang} = 0; + $percent_as{$lang} = 0; } if ($wml{$lang} > 0) { $percent_t{$lang} = int ($translated{$lang}/$wml{$lang} * 100 + .5); + $percent_ts{$lang} = (int ($translated_s{$lang}/($wml_s{$lang}+1) * 1000 + .5))/10; } else { $percent_t{$lang} = 0; + $percent_ts{$lang} = 0; } $percent_o{$lang} = 100 - $percent_t{$lang}; + $percent_os{$lang} = 100 - $percent_ts{$lang}; $percent_u{$lang} = 100 - $percent_a{$lang}; + $percent_us{$lang} = 100 - $percent_as{$lang}; if (open (HTML, ">$config{'htmldir'}/$l.html")) { printf HTML "%s: %s\n", $config{'title'}, ucfirst $lang; @@ -357,11 +386,17 @@ foreach $lang (@search_in) { printf HTML "

%s: %s

", $config{'title'}, ucfirst $lang; print HTML "\n"; - printf HTML "%d files (%d%%) translated", $wml{$lang}, $percent_a{$lang}; - printf HTML "%d files (%d%%) up to date", $translated{$lang}, $percent_t{$lang}; - printf HTML "%d files (%d%%) outdated", $outdated{$lang}, $percent_o{$lang}; + printf HTML "%d files (%d%%) translated", $wml{$lang}, $percent_a{$lang}; + printf HTML "%d files (%d%%) up to date", $translated{$lang}, $percent_t{$lang}; + printf HTML "%d files (%d%%) outdated", $outdated{$lang}, $percent_o{$lang}; printf HTML "%d files (%d%%) not translated", $untranslated{$lang}, $percent_u{$lang}; print HTML "\n"; + print HTML "\n"; + printf HTML "%d bytes (%.1f%%) translated", $wml_s{$lang}, $percent_as{$lang}; + printf HTML "%d bytes (%.1f%%) up to date", $translated_s{$lang}, $percent_ts{$lang}; + printf HTML "%d bytes (%.1f%%) outdated", $outdated_s{$lang}, $percent_os{$lang}; + printf HTML "%d bytes (%.1f%%) not translated", $nsize-$wml_s{$lang}, $percent_us{$lang}; + print HTML "\n"; print HTML "\n"; # Make the table of content @@ -398,7 +433,9 @@ foreach $lang (@search_in) { } if ($u_body) { print HTML "

Pages not translated: (top)

\n"; + print HTML "\n"; print HTML $u_body; + print HTML "
\n"; } if ($t_body) { print HTML "

Translations up to date: (top)

\n"; @@ -419,9 +456,9 @@ foreach $lang (@search_in) { $color_u = get_color (100 - $percent_po_u{$domain}{$lang}); print HTML "$domain.$langs{$lang}.po"; - printf HTML "%d (%d%%)", $color_t, $po_translated{$domain}{$lang}, $percent_po_t{$domain}{$lang}; - printf HTML "%d (%d%%)", $color_f, $po_fuzzy{$domain}{$lang}, $percent_po_f{$domain}{$lang}; - printf HTML "%d (%d%%)", $color_u, $po_untranslated{$domain}{$lang}, $percent_po_u{$domain}{$lang}; + printf HTML "%d (%s%%)", $color_t, $po_translated{$domain}{$lang}, $percent_po_t{$domain}{$lang}; + printf HTML "%d (%s%%)", $color_f, $po_fuzzy{$domain}{$lang}, $percent_po_f{$domain}{$lang}; + printf HTML "%d (%s%%)", $color_u, $po_untranslated{$domain}{$lang}, $percent_po_u{$domain}{$lang}; printf HTML "%d", $po_total{$domain}; print HTML "\n"; } @@ -472,16 +509,44 @@ foreach $lang (@search_in) { print HTML ""; printf HTML "%s (%s)", $l, ucfirst $lang, $l; - printf HTML "%d(%d%%)", $color_a, $wml{$lang}, $percent_a{$lang}; - printf HTML "%d(%d%%)", $color_t, $translated{$lang}, $percent_t{$lang}; - printf HTML "%d(%d%%)", $color_o, $outdated{$lang}, $percent_o{$lang}; - printf HTML "%d(%d%%)", $color_u, $untranslated{$lang}, $percent_u{$lang}; + printf HTML "%d(%s%%)", $color_a, $wml{$lang}, format3($percent_a{$lang}); + printf HTML "%d(%s%%)", $color_t, $translated{$lang}, format3($percent_t{$lang}); + printf HTML "%d(%s%%)", $color_o, $outdated{$lang}, format3($percent_o{$lang}); + printf HTML "%d(%s%%)", $color_u, $untranslated{$lang}, format3($percent_u{$lang}); print HTML "\n"; } } print HTML "\n"; print HTML $border_foot; +print HTML "

Translated web pages (by size)

\n"; +printf HTML "

There are %d bytes to translate.

\n",($wml_s{'english'}+$untranslated_s{'english'}); + +print HTML $border_head; +print HTML "\n"; +print HTML "\n"; + +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}); + + print HTML ""; + printf HTML "", $l, ucfirst $lang, $l; + printf HTML "", $color_a, $wml_s{$lang}, format5($percent_as{$lang}); + printf HTML "", $color_t, $translated_s{$lang}, format5($percent_ts{$lang}); + printf HTML "", $color_o, $outdated_s{$lang}, format5($percent_os{$lang}); + printf HTML "", $color_u, $wml_s{"english"}-$wml_s{$lang}, format5($percent_us{$lang}); + print HTML "\n"; + } +} +print HTML "
LanguageTranslationsUp to dateOutdatedNot translated
%s (%s)%d(%s%%)%d(%s%%)%d(%s%%)%d(%s%%)
\n"; +print HTML $border_foot; + print HTML "

Translated templates (gettext files)

\n"; printf HTML "

There are %d strings to translate.

\n",$po_total{'total'}; print HTML $border_head; @@ -497,9 +562,9 @@ foreach $lang (@search_in) { $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}); - printf HTML "%d(%d%%)", $color_t, $po_translated{'total'}{$lang}, $percent_po_t{'total'}{$lang}; - printf HTML "%d(%d%%)", $color_f, $po_fuzzy{'total'}{$lang}, $percent_po_f{'total'}{$lang}; - printf HTML "%d(%d%%)", $color_u, $po_untranslated{'total'}{$lang}, $percent_po_u{'total'}{$lang}; + printf HTML "%d(%s%%)", $color_t, $po_translated{'total'}{$lang}, format3($percent_po_t{'total'}{$lang}); + printf HTML "%d(%s%%)", $color_f, $po_fuzzy{'total'}{$lang}, format3($percent_po_f{'total'}{$lang}); + printf HTML "%d(%s%%)", $color_u, $po_untranslated{'total'}{$lang}, format3($percent_po_u{'total'}{$lang}); print HTML "\n"; } } -- cgit v1.2.3