r51198 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51197‎ | r51198 | r51199 >
Date:17:05, 30 May 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
Bugfix when no keys left after filtering
Load the stuff from file to give consistent readings
Modified paths:
  • /trunk/extensions/Translate/MessageCollection.php (modified) (history)
  • /trunk/extensions/Translate/SpecialLanguageStats.php (modified) (history)
  • /trunk/extensions/Translate/groups/MediaWikiExtensions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/groups/MediaWikiExtensions.php
@@ -209,7 +209,13 @@
210210 }
211211
212212 public function load( $code ) {
213 - return array(); // no-op
 213+ $this->init();
 214+ $array = array();
 215+ foreach ( $this->classes as $class ) {
 216+ // Use wfArrayMerge because of string keys
 217+ $array = wfArrayMerge( $array, $class->load( $code ) );
 218+ }
 219+ return $array;
214220 }
215221
216222 public function getMessage( $key, $code ) {
Index: trunk/extensions/Translate/MessageCollection.php
@@ -269,6 +269,8 @@
270270
271271 protected function loadInfo( array $keys ) {
272272 if ( $this->dbInfo !== null ) return;
 273+
 274+ $this->dbInfo = array(); // Something iterable
273275 if ( !count($keys) ) return;
274276
275277 $dbr = wfGetDB( DB_SLAVE );
@@ -295,6 +297,8 @@
296298
297299 protected function loadData( $keys ) {
298300 if ( $this->dbData !== null ) return;
 301+
 302+ $this->dbData = array(); // Something iterable
299303 if ( !count($keys) ) return;
300304
301305 $dbr = wfGetDB( DB_SLAVE );
Index: trunk/extensions/Translate/SpecialLanguageStats.php
@@ -207,6 +207,7 @@
208208
209209 // Initialise messages
210210 $collection = $g->initCollection( $code );
 211+ $collection->setInFile( $g->load( $code ) );
211212 $collection->filter( 'ignored' );
212213 $collection->filter( 'optional' );
213214 // Store the count of real messages for later calculation.
@@ -234,9 +235,18 @@
235236 continue;
236237 }
237238
238 - $translatedPercentage = wfMsg( 'percent', $wgLang->formatNum( round( 100 * $translated / $total, 2 ) ) );
239 - $fuzzyPercentage = wfMsg( 'percent', $wgLang->formatNum( round( 100 * $fuzzy / $total, 2 ) ) );
 239+ $translatedPercentage = $wgLang->formatNum( round( 100 * $translated / $total, 2 ) );
 240+ $fuzzyPercentage = $wgLang->formatNum( round( 100 * $fuzzy / $total, 2 ) );
240241
 242+ if ( !wfEmptyMsg( 'percent', wfMsgNoTrans('percent')) ) {
 243+ $translatedPercentage = wfMsg( 'percent', $translatedPercentage );
 244+ $fuzzyPercentage = wfMsg( 'percent', $fuzzyPercentage );
 245+ } else {
 246+ // For 1.14 compatability
 247+ $translatedPercentage = "$translatedPercentage%";
 248+ $fuzzyPercentage = "$fuzzyPercentage%";
 249+ }
 250+
241251 $translateTitle = SpecialPage::getTitleFor( 'Translate' );
242252 $queryParameters = array(
243253 'group' => $g->getId(),

Status & tagging log