r36312 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36311‎ | r36312 | r36313 >
Date:20:57, 15 June 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* new options to groupStatistics.php: --fuzzy and --skipzero
Modified paths:
  • /trunk/extensions/Translate/README (modified) (history)
  • /trunk/extensions/Translate/groupStatistics.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/groupStatistics.php
@@ -40,6 +40,8 @@
4141 --help : this helpful message
4242 --groups : comma separated list of groups
4343 --skiplanguages : comma separated list of languages that should be skipped
 44+ --skipzero : skip languages that don't have any localisation at all
 45+ --fuzzy : add column for fuzzy counts
4446 --output : select an output engine one of:
4547 * 'csv' : Comma Separated Values.
4648 * 'wiki' : MediaWiki syntax (default).
@@ -111,6 +113,9 @@
112114 foreach ( $groups as $g ) {
113115 // Add unprocessed description of group as heading
114116 $out->element( $g->getLabel(), true );
 117+ if ( isset($options['fuzzy']) ) {
 118+ $out->element( 'Fuzzy', true );
 119+ }
115120 }
116121 $out->blockend();
117122
@@ -120,11 +125,9 @@
121126 // Skip list
122127 if ( in_array( $code, $skipLanguages ) ) continue;
123128
124 - $out->blockstart();
125 - $out->element( $code );
126 - $out->element( $name );
 129+ $allZero = true;
 130+ $columns = array();
127131
128 -
129132 foreach ( $groups as $g ) {
130133 // Initialise messages
131134 $messages = $g->initCollection( $code );
@@ -139,6 +142,7 @@
140143
141144 // Store the count of real messages for later calculation.
142145 $total = count( $messages );
 146+ $fuzzy = 0;
143147
144148 // Get all translations. Could this be done more efficient?
145149 $g->fillCollection( $messages );
@@ -148,18 +152,33 @@
149153 if ( $messages[$key]->translation === null ) {
150154 unset( $messages[$key] );
151155 } elseif ( $messages[$key]->fuzzy ) {
 156+ $fuzzy++;
152157 unset( $messages[$key] );
153158 }
154159 }
155160
156161 // Count the completion percent and output it
157162 $translated = count( $messages );
 163+ if ( $translated !== 0 ) $allZero = false;
158164
159 - $out->element( $out->formatPercent( $translated, $total,
160 - /* Inverted color */ false, /* Decimals */ 2 )
161 - );
 165+ $columns[] = $out->formatPercent( $translated, $total,
 166+ /* Inverted color */ false, /* Decimals */ 2 );
 167+
 168+ if ( isset($options['fuzzy']) ) {
 169+ $columns[] = $out->formatPercent( $fuzzy, $total,
 170+ /* Inverted color */ true, /* Decimals */ 2 );
 171+ }
 172+
162173 }
163174
 175+ if ( $allZero && isset($options['skipzero']) ) continue;
 176+
 177+ $out->blockstart();
 178+ $out->element( $code );
 179+ $out->element( $name );
 180+
 181+ foreach ( $columns as $c ) $out->element( $c );
 182+
164183 $out->blockend();
165184 }
166185
Index: trunk/extensions/Translate/README
@@ -48,6 +48,7 @@
4949 * support for having messages in namespaces other than NS_MEDIAWIKi
5050 * try to load qqq from files if not found from the database
5151 * added $wgTranslateAuthorBlacklist
 52+* new options to groupStatistics.php: --fuzzy and --skipzero
5253
5354 == Changes in version 8 ==
5455 * Released 2008-02-06

Status & tagging log