http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89486

Revision: 89486
Author:   nikerabbit
Date:     2011-06-05 07:56:49 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
* Add overall row
* Include gettext documentation in stats for qqq

Modified Paths:
--------------
    trunk/extensions/Translate/Translate.i18n.php
    trunk/extensions/Translate/specials/SpecialLanguageStats.php

Modified: trunk/extensions/Translate/Translate.i18n.php
===================================================================
--- trunk/extensions/Translate/Translate.i18n.php       2011-06-04 22:10:24 UTC 
(rev 89485)
+++ trunk/extensions/Translate/Translate.i18n.php       2011-06-05 07:56:49 UTC 
(rev 89486)
@@ -242,6 +242,7 @@
        'translate-languagestats-groups' => ' # Add message group IDs, one per 
line to restrict the message groups that
  # are shown on Special:LanguageStats. Non-existing message group IDs will
  # be ignored.', # do not duplicate this message to other languages
+       'translate-languagestats-overall' => 'All message groups together',
 
        # Special:SupportedLanguages
        'supportedlanguages' => 'Supported languages',

Modified: trunk/extensions/Translate/specials/SpecialLanguageStats.php
===================================================================
--- trunk/extensions/Translate/specials/SpecialLanguageStats.php        
2011-06-04 22:10:24 UTC (rev 89485)
+++ trunk/extensions/Translate/specials/SpecialLanguageStats.php        
2011-06-05 07:56:49 UTC (rev 89486)
@@ -206,6 +206,7 @@
        function getGroupStats( $code, $suppressComplete = false ) {
                $this->code = $code;
                $this->suppressComplete = $suppressComplete;
+               $this->totals = array( 0, 0, 0 );
 
                $out = '';
 
@@ -220,6 +221,7 @@
 
                if ( $out ) {
                        $out = $this->createHeader( $code ) . "\n" . $out;
+                       $out .= $this->makeTotalRow( $this->totals );
                        $out .= Xml::closeElement( 'tbody' );
                        $out .= Xml::closeElement( 'table' );
                } else {
@@ -229,6 +231,36 @@
                return $out;
        }
 
+       protected function makeTotalRow( $numbers ) {
+               list( $fuzzy, $translated, $total ) = $numbers;
+               $out  = "\t" . Html::openElement( 'tr' );
+               $out .= "\n\t\t" . Html::rawElement( 'td', array(), wfMsg( 
'translate-languagestats-overall' ) );
+               $out .= $this->makeNumberColumns( $fuzzy, $translated, $total );
+               return $out;
+       }
+
+       protected function makeNumberColumns( $fuzzy, $translated, $total ) {
+               global $wgLang;
+               $out  = "\n\t\t" . Html::element( 'td',
+                       array( 'data-sort-value' => $total ),
+                       $wgLang->formatNum( $total ) );
+
+               $out .= "\n\t\t" . Html::element( 'td',
+                       array( 'data-sort-value' => $total - $translated ),
+                       $wgLang->formatNum( $total - $translated ) );
+
+               $out .= "\n\t\t" . $this->element( $this->formatPercentage( 
$translated / $total ),
+                       $this->getBackgroundColour( $translated, $total ),
+                       sprintf( '%1.3f', $translated / $total ) );
+
+               $out .= "\n\t\t" . $this->element( $this->formatPercentage( 
$fuzzy / $total ),
+                       $this->getBackgroundColour( $fuzzy, $total, true ),
+                       sprintf( '%1.3f', $fuzzy / $total ) );
+
+               $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n";
+               return $out;
+       }
+
        protected function makeGroupGroup( $item, $cache, $parent = '' ) {
                if ( !is_array( $item ) ) {
                        return $this->makeGroupRow( $item, $cache, $parent === 
'' ? false : $parent );
@@ -273,6 +305,10 @@
                        list( $fuzzy, $translated, $total ) = 
$this->loadPercentages( $cache, $g, $code );
                }
 
+               $this->totals[2] += $total;
+               $this->totals[1] += $translated;
+               $this->totals[0] += $fuzzy;
+
                if ( $total == 0 ) {
                        $zero = serialize( $total );
                        error_log( __METHOD__ . ": Group $groupName has zero 
message ($code): $zero" );
@@ -300,24 +336,7 @@
 
                $out .= "\t" . Html::openElement( 'tr', $rowParams );
                $out .= "\n\t\t" . Html::rawElement( 'td', array(), 
$this->makeGroupLink( $g, $code, $extra ) );
-
-               $out .= "\n\t\t" . Html::element( 'td',
-                       array( 'data-sort-value' => $total ),
-                       $wgLang->formatNum( $total ) );
-
-               $out .= "\n\t\t" . Html::element( 'td',
-                       array( 'data-sort-value' => $total - $translated ),
-                       $wgLang->formatNum( $total - $translated ) );
-
-               $out .= "\n\t\t" . $this->element( $this->formatPercentage( 
$translated / $total ),
-                       $this->getBackgroundColour( $translated, $total ),
-                       sprintf( '%1.3f', $translated / $total ) );
-
-               $out .= "\n\t\t" . $this->element( $this->formatPercentage( 
$fuzzy / $total ),
-                       $this->getBackgroundColour( $fuzzy, $total, true ),
-                       sprintf( '%1.3f', $fuzzy / $total ) );
-
-               $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n";
+               $out .= $this->makeNumberColumns( $fuzzy, $translated, $total );
                return $out;
        }
 
@@ -334,6 +353,20 @@
 
                // Initialise messages.
                $collection = $group->initCollection( $code );
+               
+               $ffs = $group->getFFS();
+               if ( $ffs instanceof GettextFFS && $code === 'qqq' ) {
+                       $template = $ffs->read( 'en' );
+                       $infile = array();
+                       foreach( $template['TEMPLATE'] as $key => $data ) {
+                               if ( isset( $data['comments']['.'] ) ) {
+                                       $infile[$key] = '1';
+                               }
+                       }
+                       $collection->setInFile( $infile );
+               }
+
+
                // Takes too much memory and only hides inconsistent import 
state
                # $collection->setInFile( $group->load( $code ) );
                $collection->filter( 'ignored' );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to