[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: stattrans.pl improvements



On Mon, Sep 10, 2001 at 07:00:48PM +0200, Gerfried Fuchs wrote:
> On Mon, Sep 10, 2001, Matt Kraai wrote:
> > The first hunk of this patch calculates the percentages of
> > up-to-date and outdated pages relative to the number of pages
> > translated into that language, rather than the total number of
> > pages.
> > 
> > The first part of the second hunk inverts the colorization of the
> > outdated and untranslated pages so that they are green when things
> > are good (i.e., no outdated/untranslated page) and red when things
> > are bad.
> 
>  Yes, that tweak sounds really reasonable.

I just realized that the translated/not translated and
up-to-date/outdated column pairs with always share the same color,
so there is no need to calculate it twice.

> > The second part of second hunk eliminates the special case for
> > English so that its translation statistics are also displayed on
> > the index page.
> 
>  Woooohooo!  This is all I ever wanted, and what we really need. I once
> asked about it and was frowned upon - but I think people will see that
> it helps us - like, people with originals in their language can now check
> if they forgot to update the english version, finally!

Glad to hear that it will help.

> > You can see the results of these changes at
> > http://opensource.lineo.com/~kraai/stats/.  Are any/all of these
> > changes OK?
> 
>  There is one little mistake in this page (I guess then, in the script,
> too):  The untranslated files have the same % like the translated files,
> although the numbers differ.  The translated % seems to be the correct
> one.

Actually, this was generated by an old version of the script.
I've regenerated, and the percentages are now correct.

>  Maybe you should add a second <th> row below "Up to date" and
> "Outdated" which says "percents relative to translated" or such, to not
> let come up any confusion.  Maybe in a small font or such.

If it is really confusing, I'd rather restructure the table as
follows:

Language		Translated		Untranslated
		Up-to-date	Out-of-date

Catalan (ca)		18 (1%)			953 (98%)
		14 (77%)	4 (22%)
...
Turkish (tr)		30 (3%)			941 (96%)
		24 (80%)	6 (20%)

Anyway, here is a slightly improved patch.  It's output
(up-to-date this time) is available at the same place.  It also
changes the percentage calculation so that they always add up to
100 (it rounds pessimistically).

Matt

Index: stattrans.pl
===================================================================
RCS file: /cvs/webwml/webwml/stattrans.pl,v
retrieving revision 1.25
diff -u -r1.25 stattrans.pl
--- stattrans.pl	2001/09/07 21:46:20	1.25
+++ stattrans.pl	2001/09/10 18:12:51
@@ -260,10 +260,10 @@
     $wml{$lang} = $translated{$lang};
     $translated{$lang} = $translated{$lang} - $outdated{$lang};
 
-    $percent_a{$lang} = $wml{$lang}/$wml{english} * 100;
-    $percent_t{$lang} = $translated{$lang}/$wml{english} * 100;
-    $percent_o{$lang} = $outdated{$lang}/$wml{english} * 100;
-    $percent_u{$lang} = $untranslated{$lang}/$wml{english} * 100;
+    $percent_a{$lang} = int($wml{$lang}/$wml{english} * 100);
+    $percent_t{$lang} = int($translated{$lang}/$wml{$lang} * 100);
+    $percent_o{$lang} = 100 - $percent_t{$lang};
+    $percent_u{$lang} = 100 - $percent_a{$lang};
 
     if (open (HTML, ">$config{'htmldir'}/$l.html")) {
 	printf HTML "<html><head><title>%s: %s</title></head><body bgcolor=#ffffff>\n", $config{'title'}, ucfirst $lang;
@@ -331,19 +331,13 @@
 
     $color_a = get_color ($percent_a{$lang});
     $color_t = get_color ($percent_t{$lang});
-    $color_o = get_color ($percent_o{$lang});
-    $color_u = get_color ($percent_u{$lang});
 
     print HTML "<tr>";
     printf HTML "<td><a href=\"%s.html\">%s</a> (%s)</td>", $l, ucfirst $lang, $l;
     printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_a, $wml{$lang}, $percent_a{$lang};
-    if ($l ne "en") {
-      printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_t, $translated{$lang}, $percent_t{$lang};
-      printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_o, $outdated{$lang}, $percent_o{$lang};
-      printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_u, $untranslated{$lang}, $percent_u{$lang};
-    } else {
-      print HTML "<td bgcolor=\"#00FF00\" align=right>-</td><td bgcolor=\"#00FF00\" align=right>-</td><td bgcolor=\"#FF0000\" align=right>-</td>";
-    }
+    printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_t, $translated{$lang}, $percent_t{$lang};
+    printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_t, $outdated{$lang}, $percent_o{$lang};
+    printf HTML "<td bgcolor=\"%s\" align=right>%d (%d%%)</td>", $color_a, $untranslated{$lang}, $percent_u{$lang};
     print HTML "</tr>\n",
 }
 



Reply to: