r57416 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57415‎ | r57416 | r57417 >
Date:07:08, 6 October 2009
Author:siebrand
Status:deferred
Tags:
Comment:
i18n for wiki output of groupStatistics.php
Modified paths:
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)
  • /trunk/extensions/Translate/scripts/groupStatistics.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/groupStatistics.php
@@ -3,8 +3,10 @@
44 * Statistics about message groups.
55 *
66 * @author Niklas Laxstrom
 7+ * @author Siebrand Mazeland
78 *
89 * @copyright Copyright © 2007-2008, Niklas Laxström
 10+ * @copyright Copyright © 2009, Siebrand Mazeland
911 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1012 * @file
1113 */
@@ -178,6 +180,13 @@
179181 }
180182 }
181183
 184+// check if l10n should be done
 185+$l10n = false;
 186+if( ( $options['output'] == 'wiki' || $options['output'] == 'default' ) &&
 187+ !isset( $options['nol10n'] ) ) {
 188+ $l10n = true;
 189+}
 190+
182191 // Get groups from input
183192 $groups = array();
184193 if( $reportScore ) {
@@ -211,17 +220,17 @@
212221
213222 // Add header column for language size
214223 if( isset( $options['most'] ) ) {
215 - $out->element( 'Pos.', true );
 224+ $out->element( ( $l10n ? "{{int:translate-gs-pos" : 'Pos.' ), true );
216225 }
217226 $out->element( 'Code', true );
218 -$out->element( 'Language', true );
 227+$out->element( ( $l10n ? "{{int:translate-page-language}}" : 'Language' ), true );
219228 if( ( $options['output'] == 'wiki' || $options['output'] == 'default' ) &&
220229 isset( $options['continent'] ) ) {
221 - $out->element( 'Continent', true );
 230+ $out->element( ( $l10n ? "{{int:translate-gs-continent}}" : 'Continent' ), true );
222231 }
223232
224233 if( isset( $options['most'] ) && isset( $options['speakers'] ) ) {
225 - $out->element( 'Speakers', true );
 234+ $out->element( ( $l10n ? "{{int:translate-gs-speakers}}" : 'Speakers' ), true );
226235 }
227236
228237 $totalWeight = 0;
@@ -229,7 +238,7 @@
230239 foreach( $localisedWeights[$options['most']] as $weight ) {
231240 $totalWeight += $weight;
232241 }
233 - $out->element( 'Score (' . $totalWeight . ')', true );
 242+ $out->element( ( $l10n ? "{{int:translate-gs-score}}" : 'Score' ) . ' (' . $totalWeight . ')', true );
234243 }
235244
236245 foreach ( $groups as $g ) {
@@ -242,7 +251,7 @@
243252 }
244253 $out->element( $heading, true );
245254 if ( !$reportScore && isset( $options['fuzzy'] ) ) {
246 - $out->element( 'Fuzzy', true );
 255+ $out->element( ( $l10n ? "{{int:translate-percentage-fuzzy}}" : 'Fuzzy' ), true );
247256 }
248257 }
249258
@@ -299,7 +308,6 @@
300309 if ( isset( $options['fuzzy'] ) ) {
301310 $rows[$code][] = array( true, $fuzzy, $total );
302311 }
303 -
304312 }
305313
306314 $cache->commit(); // Do not keep open too long to avoid concurrent access
@@ -346,9 +354,7 @@
347355 $out->element( $code );
348356
349357 // Fill language name field
350 - if( ( $options['output'] == 'wiki' || $options['output'] == 'default' ) &&
351 - !isset( $options['nol10n'] ) &&
352 - function_exists( 'efI18nTagsInit' ) ) {
 358+ if( $l10n && function_exists( 'efI18nTagsInit' ) ) {
353359 $out->element( "{{#languagename:" . $code . "}}" );
354360 } else {
355361 $out->element( $name );
@@ -358,9 +364,9 @@
359365 if( ( $options['output'] == 'wiki' || $options['output'] == 'default' ) &&
360366 isset( $options['continent'] ) ) {
361367 if( $mostSpokenLanguages[$code][2] == 'multiple' ) {
362 - $continent = '';
 368+ $continent = ( $l10n ? "{{int:translate-gs-multiple}}" : 'Multiple' );
363369 } else {
364 - $continent = isset( $options['nol10n'] ) ?
 370+ $continent = $l10n ?
365371 ucfirst ( $mostSpokenLanguages[$code][2] ) :
366372 "{{int:timezoneregion-" . $mostSpokenLanguages[$code][2] . "}}";
367373 }
@@ -421,9 +427,9 @@
422428
423429 $out->blockstart();
424430
425 - $out->element( 'Continent', true );
426 - $out->element( 'Count', true );
427 - $out->element( 'Avg. score', true );
 431+ $out->element( $l10n ? "{{int:translate-gs-continent}}" : 'Continent', true );
 432+ $out->element( $l10n ? "{{int:translate-gs-count}}" : 'Count', true );
 433+ $out->element( $l10n ? "{{int:translate-gs-avgscore}}" : 'Avg. score', true );
428434
429435 $out->blockend();
430436
@@ -435,9 +441,9 @@
436442 $out->blockstart();
437443
438444 if( $key == 'multiple' ) {
439 - $out->element( 'Multiple' );
 445+ $out->element( $l10n ? "{{int:translate-gs-multiple}}" : 'Multiple' );
440446 } else {
441 - $out->element( "{{int:timezoneregion-" . $key . "}}" );
 447+ $out->element( $l10n ? "{{int:timezoneregion-" . $key . "}}" : ucfirst( $key ) );
442448 }
443449 $out->element( $values[0] );
444450 $out->element( number_format( $values[1]/$values[0] ) );
@@ -449,7 +455,7 @@
450456 }
451457
452458 $out->blockstart();
453 - $out->element( 'Total' );
 459+ $out->element( $l10n ? "{{int:translate-gs-total}}" : 'Total' );
454460 $out->element( $totals[0] );
455461 $out->element( number_format( $totals[1]/$totals[0] ) );
456462 $out->blockend();
Index: trunk/extensions/Translate/Translate.i18n.php
@@ -308,6 +308,17 @@
309309 Details: $1',
310310
311311 'translate-js-fb' => 'Normal edit',
 312+
 313+ // scripts/groupStatistics.php related messages
 314+ 'translate-gs-pos' => 'Pos.',
 315+ 'translate-gs-code' => 'Code',
 316+ 'translate-gs-continent' => 'Continent',
 317+ 'translate-gs-speakers' => 'Speakers',
 318+ 'translate-gs-score' => 'Score',
 319+ 'translate-gs-multiple' => 'Multiple',
 320+ 'translate-gs-count' => 'Count',
 321+ 'translate-gs-total' => 'Total',
 322+ 'translate-gs-avgscore' => 'Avg. score',
312323 );
313324
314325 /** Message documentation (Message documentation)

Status & tagging log