https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113141

Revision: 113141
Author:   santhosh
Date:     2012-03-06 14:36:46 +0000 (Tue, 06 Mar 2012)
Log Message:
-----------
Correct the filtering of languages for MessageGroup stats. It should only list 
prioriy langs and languages with more than 0% translatations.
Follow up r113124

Modified Paths:
--------------
    trunk/extensions/Translate/specials/SpecialMessageGroupStats.php

Modified: trunk/extensions/Translate/specials/SpecialMessageGroupStats.php
===================================================================
--- trunk/extensions/Translate/specials/SpecialMessageGroupStats.php    
2012-03-06 14:32:45 UTC (rev 113140)
+++ trunk/extensions/Translate/specials/SpecialMessageGroupStats.php    
2012-03-06 14:36:46 UTC (rev 113141)
@@ -134,7 +134,7 @@
 
                $languages = array_keys( Language::getLanguageNames( false ) );
                sort( $languages );
-
+               $this->filterPriorityLangs( $languages,  $this->target, $cache 
);
                foreach ( $languages as $code ) {
                        if ( $table->isBlacklisted( $this->target, $code ) !== 
null ) {
                                continue;
@@ -160,6 +160,31 @@
        }
 
        /**
+        * Filter an array of languages based on whether a priority set of 
languages present for the passed group.
+        * If priority languages are present, to that list add languages with 
more than 0% translation.
+        * @param $languages Array of Languages to be filtered
+        * @param $group
+        * @param $cache
+        */
+       protected function filterPriorityLangs( &$languages, $group, $cache ) {
+               $filterLangs = TranslateMetadata::get( $group, 'prioritylangs' 
);
+               if ( strlen( $filterLangs ) === 0 ) {
+                       // No restrictions, keep everything
+                       return;
+               }
+               $filter = array_flip( explode( ',', $filterLangs ) );
+               foreach ( $languages as $id => $code ) {
+                       if ( isset( $filter[$code] ) ) {
+                               continue;
+                       }
+                       $translated = $cache[$code][1];
+                       if ( $translated === 0 ) {
+                               unset( $languages[$id] );
+                       }
+               }
+       }
+
+       /**
         * @param $code
         * @param $cache
         * @return string
@@ -172,7 +197,7 @@
                        $this->incomplete = true;
                        $extra = array();
                } else {
-                       if( $total === 0 ) {
+                       if ( $total === 0 ) {
                                error_log( __METHOD__ . ": $code has 0 
messages." );
                        }
 


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

Reply via email to