http://www.mediawiki.org/wiki/Special:Code/MediaWiki/56276
Revision: 56276
Author: siebrand
Date: 2009-09-13 17:51:24 +0000 (Sun, 13 Sep 2009)
Log Message:
-----------
* format numbers to 2 decimals
* deal with error cases (no background colour, no percentage)
Modified Paths:
--------------
trunk/extensions/Translate/SpecialLanguageStats.php
Modified: trunk/extensions/Translate/SpecialLanguageStats.php
===================================================================
--- trunk/extensions/Translate/SpecialLanguageStats.php 2009-09-13 17:46:49 UTC
(rev 56275)
+++ trunk/extensions/Translate/SpecialLanguageStats.php 2009-09-13 17:51:24 UTC
(rev 56276)
@@ -170,6 +170,7 @@
function getGroupStats( $code, $suppressComplete = false ) {
global $wgUser, $wgLang;
+ $errorString = '<error>';
$out = '';
$cache = new ArrayMemoryCache( 'groupstats' );
@@ -209,13 +210,13 @@
continue;
}
- // Division by 0 should not be possible, but does
ooccur. Caching issue?
- $translatedPercentage = $total ? $wgLang->formatNum(
round( 100 * $translated / $total, 2 ) ) : '<error>';
- $fuzzyPercentage = $total ? $wgLang->formatNum( round(
100 * $fuzzy / $total, 2 ) ) : '<error>';
+ // Division by 0 should not be possible, but does
occur. Caching issue?
+ $translatedPercentage = $total ? $wgLang->formatNum(
number_format( round( 100 * $translated / $total, 2 ), 2 ) ) : $errorString;
+ $fuzzyPercentage = $total ? $wgLang->formatNum(
number_format( round( 100 * $fuzzy / $total, 2 ), 2 ) ) : $errorString;
- if ( !wfEmptyMsg( 'percent', wfMsgNoTrans('percent')) )
{
- $translatedPercentage = wfMsg( 'percent',
$translatedPercentage );
- $fuzzyPercentage = wfMsg( 'percent',
$fuzzyPercentage );
+ if ( !wfEmptyMsg( 'percent', wfMsgNoTrans('percent') )
) {
+ $translatedPercentage = $translatedPercentage
== $errorString ? $translatedPercentage : wfMsg( 'percent',
$translatedPercentage );
+ $fuzzyPercentage = $fuzzyPercentage ==
$errorString ? $fuzzyPercentage : wfMsg( 'percent', $fuzzyPercentage );
} else {
// For 1.14 compatability
$translatedPercentage =
"$translatedPercentage%";
@@ -239,8 +240,8 @@
$out .= $this->element( $translateGroupLink );
$out .= $this->element( $total );
$out .= $this->element( $total - $translated );
- $out .= $this->element( $translatedPercentage, false,
$this->getBackgroundColour( $translated, $total ) );
- $out .= $this->element( $fuzzyPercentage, false,
$this->getBackgroundColour( $fuzzy, $total, true ) );
+ $out .= $this->element( $translatedPercentage, false,
$translatedPercentage == $errorString ? '' : $this->getBackgroundColour(
$translated, $total ) );
+ $out .= $this->element( $fuzzyPercentage, false,
$translatedPercentage == $errorString ? '' : $this->getBackgroundColour(
$fuzzy, $total, true ) );
$out .= $this->blockend();
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs