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

Re: stattrans.pl



On Thu, Sep 13, 2001 at 04:37:43PM +0200, Gerfried Fuchs wrote:
>  I object to the last changes to the stattrans.pl script :)  I am going
> to submit the following diff for the file:
> 
> ===================================================================
> RCS file: /cvs/webwml/webwml/stattrans.pl,v
> retrieving revision 1.29
> diff -u -r1.29 stattrans.pl
> --- stattrans.pl        2001/09/12 19:14:15     1.29
> +++ stattrans.pl        2001/09/13 14:32:42
> @@ -262,9 +262,9 @@
>      $wml{$lang} = $translated{$lang};
>      $translated{$lang} = $translated{$lang} - $outdated{$lang};
>  
> -    $percent_a{$lang} = int ($wml{$lang}/$nfiles * 100);
> -    $percent_t{$lang} = int ($translated{$lang}/$nfiles * 100);
> -    $percent_o{$lang} = int ($outdated{$lang}/$nfiles * 100);
> +    $percent_a{$lang} = int ($wml{$lang}/$nfiles * 100 + .5);
> +    $percent_t{$lang} = int ($translated{$lang}/$nfiles * 100 + .5);
> +    $percent_o{$lang} = 100 - $percent_t{$lang};
>      $percent_u{$lang} = 100 - $percent_a{$lang};
>  
>      if (open (HTML, ">$config{'htmldir'}/$l.html")) {
> ===================================================================
> 
>  There is no need at all to calculate percent_o, it's just the inverse
> to percent_t, like percent_u is for percent_a.  If you don't believe
> please think of it.  $outdated == $nfiles - $translated, and therefore
> it yields the same value.  So if we don't calculate percent_u we should
> stop calculating percent_o too, if it's for performance-reasons.

This is true only if you consider all of the untranslated files to
be outdated translations.  I originally made this exact mistake,
but corrected it after committing it.  Please see the CVS log.
I've been rethinking this, though.  It might be better to replace
it with the following:

 $percent_o{$lang} = $percent_a{$lang} - $percent_t{$lang};

>  Also, if we are going to int() the value of the percentage we should
> round it properly, therefore the .5 - which I earlier sugguested.  If
> the int is removed the .5 should be removed in this place too, but as
> long as it's int() the .5 should stay there.

Heh, I'm a pessimist.

Matt



Reply to: