r110411 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110410‎ | r110411 | r110412 >
Date:17:24, 31 January 2012
Author:siebrand
Status:ok
Tags:
Comment:
Stylize and whitespace updates.
Modified paths:
  • /trunk/extensions/Translate/Groups.php (modified) (history)
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)
  • /trunk/extensions/Translate/TranslateUtils.php (modified) (history)
  • /trunk/extensions/Translate/api/ApiTTMServer.php (modified) (history)
  • /trunk/extensions/Translate/resources/ext.translate.quickedit.js (modified) (history)
  • /trunk/extensions/Translate/scripts/export.php (modified) (history)
  • /trunk/extensions/Translate/scripts/sync-group.php (modified) (history)
  • /trunk/extensions/Translate/scripts/ttmserver-export.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialLanguageStats.php (modified) (history)
  • /trunk/extensions/Translate/utils/StatsTable.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslationHelpers.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/sync-group.php
@@ -56,7 +56,7 @@
5757 foreach ( $groupIds as $groupId ) {
5858 $group = MessageGroups::getGroup( $groupId );
5959
60 - if( $group !== null ) {
 60+ if ( $group !== null ) {
6161 $groups[$groupId] = $group;
6262 } else {
6363 STDERR( "Invalid group $groupId" );
@@ -74,7 +74,7 @@
7575 }
7676 }
7777
78 -if( !count( $groups ) ) {
 78+if ( !count( $groups ) ) {
7979 STDERR( "ESG2: No valid message groups identified." );
8080 exit( 1 );
8181 }
Index: trunk/extensions/Translate/scripts/ttmserver-export.php
@@ -33,7 +33,7 @@
3434 protected function statusLine( $text, $channel = null ) {
3535 $pid = sprintf( "%5s", getmypid() );
3636 $prefix = sprintf( "%6.2f", microtime( true ) - $this->start );
37 - $mem = sprintf( "%5.1fM", ( memory_get_usage( true ) / (1024*1024) ) );
 37+ $mem = sprintf( "%5.1fM", ( memory_get_usage( true ) / ( 1024 * 1024 ) ) );
3838 $this->output( "$pid $prefix $mem $text", $channel );
3939 }
4040
@@ -53,7 +53,7 @@
5454 $this->output( 'fulltext.. ', 1 );
5555 $dbw->delete( 'translate_tmf', '*', __METHOD__ );
5656 $table = $dbw->tableName( 'translate_tmf' );
57 - #$dbw->query( "DROP INDEX tmf_text ON $table" );
 57+ # $dbw->query( "DROP INDEX tmf_text ON $table" );
5858 $this->output( 'done!', 1 );
5959
6060 $this->statusLine( 'Loading groups... ', 2 );
@@ -187,7 +187,7 @@
188188 $this->output( '.', $targetLanguage );
189189 }
190190 wfWaitForSlaves( 10 );
191 - } while( count( $inserts ) );
 191+ } while ( count( $inserts ) );
192192 }
193193
194194 if ( $multi ) {
Index: trunk/extensions/Translate/scripts/export.php
@@ -99,7 +99,7 @@
100100 foreach ( $groupIds as $groupId ) {
101101 $group = MessageGroups::getGroup( $groupId );
102102
103 - if( $group !== null ) {
 103+ if ( $group !== null ) {
104104 $groups[$groupId] = $group;
105105 } else {
106106 STDERR( "Invalid group $groupId" );
Index: trunk/extensions/Translate/utils/StatsTable.php
@@ -32,6 +32,7 @@
3333
3434 public function __construct() {
3535 global $wgLang;
 36+
3637 $this->lang = $wgLang;
3738 $this->translate = SpecialPage::getTitleFor( 'Translate' );
3839 }
@@ -46,13 +47,18 @@
4748 */
4849 public function element( $in, $bgcolor = '', $sort = '' ) {
4950 $attributes = array();
50 - if ( $sort ) $attributes['data-sort-value'] = $sort;
 51+
 52+ if ( $sort ) {
 53+ $attributes['data-sort-value'] = $sort;
 54+ }
 55+
5156 if ( $bgcolor ) {
5257 $attributes['style'] = "background-color: #" . $bgcolor;
5358 $attributes['class'] = 'hover-color';
5459 }
5560
5661 $element = Html::element( 'td', $attributes, $in );
 62+
5763 return $element;
5864 }
5965
@@ -62,7 +68,11 @@
6369 if ( $fuzzy ) {
6470 // Weigh fuzzy with factor 20.
6571 $v = $v * 20;
66 - if ( $v > 255 ) $v = 255;
 72+
 73+ if ( $v > 255 ) {
 74+ $v = 255;
 75+ }
 76+
6777 $v = 255 - $v;
6878 }
6979
@@ -134,10 +144,12 @@
135145 */
136146 public function makeTotalRow( Message $message, $numbers ) {
137147 list( $total, $translated, $fuzzy ) = $numbers;
 148+
138149 $out = "\t" . Html::openElement( 'tr' );
139150 $out .= "\n\t\t" . Html::element( 'td', array(), $message->text() );
140151 $out .= $this->makeNumberColumns( $fuzzy, $translated, $total );
141152 $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n";
 153+
142154 return $out;
143155 }
144156
@@ -153,6 +165,7 @@
154166 $na = "\n\t\t" . Html::element( 'td', array( 'data-sort-value' => -1 ), '...' );
155167 $nap = "\n\t\t" . $this->element( '...', 'AFAFAF', -1 );
156168 $out = $na . $na . $nap . $nap;
 169+
157170 return $out;
158171 }
159172
@@ -181,6 +194,7 @@
182195 */
183196 public function formatPercentage( $num ) {
184197 $fmt = $this->lang->formatNum( number_format( round( 100 * $num, 2 ), 2 ) );
 198+
185199 return wfMessage( 'percent', $fmt )->text();
186200 }
187201
@@ -208,7 +222,6 @@
209223 * @return string Html
210224 */
211225 public function makeGroupLink( MessageGroup $group, $code, $params ) {
212 -
213226 $queryParameters = $params + array(
214227 'group' => $group->getId(),
215228 'language' => $code
@@ -238,19 +251,24 @@
239252 $cache = wfGetCache( CACHE_ANYTHING );
240253 $key = wfMemckey( "translate-groupdesc-$code-" . $group->getId() );
241254 $desc = $cache->get( $key );
 255+
242256 if ( is_string( $desc ) ) {
243257 return $desc;
244258 }
245259
246260 $realFunction = array( 'MessageCache', 'singleton' );
 261+
247262 if ( is_callable( $realFunction ) ) {
248263 $mc = MessageCache::singleton();
249264 } else {
250265 global $wgMessageCache;
 266+
251267 $mc = $wgMessageCache;
252268 }
 269+
253270 $desc = $mc->transform( $group->getDescription(), true, $this->lang );
254271 $cache->set( $key, $desc );
 272+
255273 return $desc;
256274 }
257275
Index: trunk/extensions/Translate/utils/TranslationHelpers.php
@@ -1083,7 +1083,7 @@
10841084 $text = wfMessage( 'translate-dynagroup-last', $user )->escaped();
10851085 }
10861086 }
1087 -
 1087+
10881088 return TranslateUtils::fieldset( $text, $diffText, array( 'class' => 'mw-sp-translate-latestchange' ) );
10891089 }
10901090
Index: trunk/extensions/Translate/Translate.i18n.php
@@ -13335,7 +13335,7 @@
1333613336 'translate-edit-definition' => 'ಸಂದೇಶ ವ್ಯಾಖ್ಯೆ',
1333713337 'translate-edit-translation' => 'ಅನುವಾದ',
1333813338 'translate-edit-contribute' => 'ನೆರವಾಗು',
13339 - 'translate-edit-no-information' => '"ಈ ಸಂದೇಶಕ್ಕೆ ಯಾವುದೇ ದಾಖಲೆಗಳಿಲ್ಲ."
 13339+ 'translate-edit-no-information' => '"ಈ ಸಂದೇಶಕ್ಕೆ ಯಾವುದೇ ದಾಖಲೆಗಳಿಲ್ಲ."
1334013340 "ನಿಮಗೆ ಈ ಸಂದೇಶ ಎಲ್ಲಿಯಾದರೂ ಅಥವಾ ಹೇಗಾದರೂ ಉಪಯೋಗದಲ್ಲಿರುವುದು ತಿಳಿದಿದ್ದರೆ,ನೀವು ಇದಕ್ಕೆ ತಕ್ಕ ದಾಖಲೆಗಳನ್ನು ಸೇರಿಸಿ ಬೇರಿ ಭಾಷಾಂತರಕಾರರಿಗೆ ಸಹಾಯ ಮಾಡಬಹುದು."',
1334113341 'translate-edit-information' => 'ಸಂದೇಶದ ಬಗ್ಗೆ ಮಾಹಿತಿ ($1)',
1334213342 'translate-edit-in-other-languages' => 'ಬೇರೆ ಭಾಷೆಗಳಲ್ಲಿ ಸಂದೇಶ',
Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php
@@ -21,7 +21,6 @@
2222 * @ingroup SpecialPage TranslateSpecialPage Stats
2323 */
2424 class SpecialLanguageStats extends IncludableSpecialPage {
25 -
2625 /**
2726 * @var StatsTable
2827 */
@@ -80,7 +79,9 @@
8180
8281 public function __construct() {
8382 parent::__construct( 'LanguageStats' );
 83+
8484 global $wgLang;
 85+
8586 $this->target = $wgLang->getCode();
8687 }
8788
@@ -99,12 +100,15 @@
100101 $wgOut->addModules( 'ext.translate.messagetable' );
101102
102103 $params = explode( '/', $par );
 104+
103105 if ( isset( $params[0] ) && trim( $params[0] ) ) {
104106 $this->target = $params[0];
105107 }
 108+
106109 if ( isset( $params[1] ) ) {
107110 $this->noComplete = (bool)$params[1];
108111 }
 112+
109113 if ( isset( $params[2] ) ) {
110114 $this->noEmpty = (bool)$params[2];
111115 }
@@ -146,12 +150,14 @@
147151 */
148152 protected function isValidValue( $value ) {
149153 $langs = Language::getLanguageNames( false );
 154+
150155 return isset( $langs[$value] );
151156 }
152157
153158 /// Called when the target is unknown.
154159 protected function invalidTarget() {
155160 global $wgOut;
 161+
156162 $wgOut->wrapWikiMsg( "<div class='error'>$1</div>", 'translate-page-no-such-language' );
157163 }
158164
@@ -233,6 +239,7 @@
234240 */
235241 function addWorkflowStatesColumn() {
236242 global $wgTranslateWorkflowStates;
 243+
237244 if ( $wgTranslateWorkflowStates ) {
238245 $this->states = self::getWorkflowStates();
239246 $this->statemap = array_flip( array_keys( $wgTranslateWorkflowStates ) );
@@ -249,11 +256,13 @@
250257 */
251258 function getWorkflowStateCell( $target ) {
252259 global $wgTranslateWorkflowStates;
 260+
253261 if ( $wgTranslateWorkflowStates ) {
254262 $state = isset( $this->states[$target] ) ? $this->states[$target] : '';
255263 $sort = isset( $this->statemap[$state] ) ? $this->statemap[$state] + 1 : -1;
256264 $stateMessage = wfMessage( "translate-workflow-state-$state" );
257265 $stateText = $stateMessage->isBlank() ? $state : $stateMessage->text();
 266+
258267 return "\n\t\t" . $this->table->element(
259268 $stateText,
260269 isset( $wgTranslateWorkflowStates[$state] ) ? $wgTranslateWorkflowStates[$state] : '',
@@ -296,14 +305,16 @@
297306 $out .= Html::closeElement( 'tfoot' );
298307
299308 $out .= Html::closeElement( 'table' );
 309+
300310 return $out;
301311 } else {
302312 $this->nothing = true;
 313+
303314 return '';
304315 }
305316
306 - /// @todo: Allow extra message here, once total translated volume goes
307 - /// over a certain percentage? (former live hack at translatewiki)
 317+ /// @todo Allow extra message here, once total translated volume goes
 318+ /// over a certain percentage? (former live hack at translatewiki)
308319 /// if ( $this->totals['2'] && ( $this->totals['1'] / $this->totals['2'] ) > 0.95 ) {
309320 /// $out .= wfMessage( 'translate-somekey' );
310321 /// }
@@ -323,10 +334,12 @@
324335 $out = '';
325336 $top = array_shift( $item );
326337 $out .= $this->makeGroupRow( $top, $cache, $parent === '' ? true : $parent );
 338+
327339 foreach ( $item as $subgroup ) {
328340 $parents = trim( $parent . ' ' . $top->getId() );
329341 $out .= $this->makeGroupGroup( $subgroup, $cache, $parents );
330342 }
 343+
331344 return $out;
332345 }
333346
@@ -377,6 +390,7 @@
378391
379392 $rowParams = array();
380393 $rowParams['data-groupid'] = $groupId;
 394+
381395 if ( is_string( $parent ) ) {
382396 $rowParams['data-parentgroups'] = $parent;
383397 } elseif ( $parent === true ) {
@@ -390,6 +404,7 @@
391405 $out .= $this->getWorkflowStateCell( $groupId );
392406
393407 $out .= "\n\t" . Html::closeElement( 'tr' ) . "\n";
 408+
394409 return $out;
395410 }
396411
@@ -413,10 +428,13 @@
414429 array( $targetCol => $this->target ),
415430 __METHOD__
416431 );
 432+
417433 $states = array();
 434+
418435 foreach ( $res as $row ) {
419436 $states[$row->$selectKey] = $row->tgr_state;
420437 }
 438+
421439 return $states;
422440 }
423441 }
Index: trunk/extensions/Translate/TranslateUtils.php
@@ -319,7 +319,7 @@
320320 $out->addModules( 'ext.translate.helplink' );
321321 $text = wfMessage( 'translate-gethelp' )->escaped();
322322
323 - if( $overrideBaseUrl ) {
 323+ if ( $overrideBaseUrl ) {
324324 $helpUrl = $to;
325325 } else {
326326 $helpUrl = "//www.mediawiki.org/wiki/Special:MyLanguage/$to";
Index: trunk/extensions/Translate/Groups.php
@@ -686,8 +686,8 @@
687687 }
688688 return $messages;
689689 }
690 -
691690
 691+
692692 public function initCollection( $code ) {
693693 $messages = $this->loadMessagesFromCache( $this->getGroups() );
694694 $namespace = $this->getNamespace();
Index: trunk/extensions/Translate/api/ApiTTMServer.php
@@ -39,7 +39,7 @@
4040
4141 protected function getAvailableTranslationServices() {
4242 global $wgTranslateTranslationServices;
43 -
 43+
4444 $good = array();
4545 foreach ( $wgTranslateTranslationServices as $id => $config ) {
4646 if ( $config['type'] === 'ttmserver' && $config['public'] === true ) {
Index: trunk/extensions/Translate/resources/ext.translate.quickedit.js
@@ -129,7 +129,7 @@
130130 var height = $( window ).height() * 0.7;
131131 dialogwidth = $( window ).width() * 0.8;
132132 mw.util.addCSS( "/* Inserted by ext.translate.quickedit */\n" +
133 - ".mw-sp-translate-edit-fields {\n" +
 133+ ".mw-sp-translate-edit-fields {\n" +
134134 "\tmax-height: " + height + "px;\n" +
135135 "\toverflow: auto\n}\n"
136136 );

Status & tagging log