r89486 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89485‎ | r89486 | r89487 >
Date:07:56, 5 June 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
* Add overall row
* Include gettext documentation in stats for qqq
Modified paths:
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialLanguageStats.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.i18n.php
@@ -242,6 +242,7 @@
243243 'translate-languagestats-groups' => ' # Add message group IDs, one per line to restrict the message groups that
244244 # are shown on Special:LanguageStats. Non-existing message group IDs will
245245 # be ignored.', # do not duplicate this message to other languages
 246+ 'translate-languagestats-overall' => 'All message groups together',
246247
247248 # Special:SupportedLanguages
248249 'supportedlanguages' => 'Supported languages',
Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php
@@ -206,6 +206,7 @@
207207 function getGroupStats( $code, $suppressComplete = false ) {
208208 $this->code = $code;
209209 $this->suppressComplete = $suppressComplete;
 210+ $this->totals = array( 0, 0, 0 );
210211
211212 $out = '';
212213
@@ -220,6 +221,7 @@
221222
222223 if ( $out ) {
223224 $out = $this->createHeader( $code ) . "\n" . $out;
 225+ $out .= $this->makeTotalRow( $this->totals );
224226 $out .= Xml::closeElement( 'tbody' );
225227 $out .= Xml::closeElement( 'table' );
226228 } else {
@@ -229,6 +231,36 @@
230232 return $out;
231233 }
232234
 235+ protected function makeTotalRow( $numbers ) {
 236+ list( $fuzzy, $translated, $total ) = $numbers;
 237+ $out = "\t" . Html::openElement( 'tr' );
 238+ $out .= "\n\t\t" . Html::rawElement( 'td', array(), wfMsg( 'translate-languagestats-overall' ) );
 239+ $out .= $this->makeNumberColumns( $fuzzy, $translated, $total );
 240+ return $out;
 241+ }
 242+
 243+ protected function makeNumberColumns( $fuzzy, $translated, $total ) {
 244+ global $wgLang;
 245+ $out = "\n\t\t" . Html::element( 'td',
 246+ array( 'data-sort-value' => $total ),
 247+ $wgLang->formatNum( $total ) );
 248+
 249+ $out .= "\n\t\t" . Html::element( 'td',
 250+ array( 'data-sort-value' => $total - $translated ),
 251+ $wgLang->formatNum( $total - $translated ) );
 252+
 253+ $out .= "\n\t\t" . $this->element( $this->formatPercentage( $translated / $total ),
 254+ $this->getBackgroundColour( $translated, $total ),
 255+ sprintf( '%1.3f', $translated / $total ) );
 256+
 257+ $out .= "\n\t\t" . $this->element( $this->formatPercentage( $fuzzy / $total ),
 258+ $this->getBackgroundColour( $fuzzy, $total, true ),
 259+ sprintf( '%1.3f', $fuzzy / $total ) );
 260+
 261+ $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n";
 262+ return $out;
 263+ }
 264+
233265 protected function makeGroupGroup( $item, $cache, $parent = '' ) {
234266 if ( !is_array( $item ) ) {
235267 return $this->makeGroupRow( $item, $cache, $parent === '' ? false : $parent );
@@ -273,6 +305,10 @@
274306 list( $fuzzy, $translated, $total ) = $this->loadPercentages( $cache, $g, $code );
275307 }
276308
 309+ $this->totals[2] += $total;
 310+ $this->totals[1] += $translated;
 311+ $this->totals[0] += $fuzzy;
 312+
277313 if ( $total == 0 ) {
278314 $zero = serialize( $total );
279315 error_log( __METHOD__ . ": Group $groupName has zero message ($code): $zero" );
@@ -300,24 +336,7 @@
301337
302338 $out .= "\t" . Html::openElement( 'tr', $rowParams );
303339 $out .= "\n\t\t" . Html::rawElement( 'td', array(), $this->makeGroupLink( $g, $code, $extra ) );
304 -
305 - $out .= "\n\t\t" . Html::element( 'td',
306 - array( 'data-sort-value' => $total ),
307 - $wgLang->formatNum( $total ) );
308 -
309 - $out .= "\n\t\t" . Html::element( 'td',
310 - array( 'data-sort-value' => $total - $translated ),
311 - $wgLang->formatNum( $total - $translated ) );
312 -
313 - $out .= "\n\t\t" . $this->element( $this->formatPercentage( $translated / $total ),
314 - $this->getBackgroundColour( $translated, $total ),
315 - sprintf( '%1.3f', $translated / $total ) );
316 -
317 - $out .= "\n\t\t" . $this->element( $this->formatPercentage( $fuzzy / $total ),
318 - $this->getBackgroundColour( $fuzzy, $total, true ),
319 - sprintf( '%1.3f', $fuzzy / $total ) );
320 -
321 - $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n";
 340+ $out .= $this->makeNumberColumns( $fuzzy, $translated, $total );
322341 return $out;
323342 }
324343
@@ -334,6 +353,20 @@
335354
336355 // Initialise messages.
337356 $collection = $group->initCollection( $code );
 357+
 358+ $ffs = $group->getFFS();
 359+ if ( $ffs instanceof GettextFFS && $code === 'qqq' ) {
 360+ $template = $ffs->read( 'en' );
 361+ $infile = array();
 362+ foreach( $template['TEMPLATE'] as $key => $data ) {
 363+ if ( isset( $data['comments']['.'] ) ) {
 364+ $infile[$key] = '1';
 365+ }
 366+ }
 367+ $collection->setInFile( $infile );
 368+ }
 369+
 370+
338371 // Takes too much memory and only hides inconsistent import state
339372 # $collection->setInFile( $group->load( $code ) );
340373 $collection->filter( 'ignored' );

Status & tagging log