r50426 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50425‎ | r50426 | r50427 >
Date:09:59, 10 May 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
* Mark outdated messages as fuzzy for translators
* Fix a bug in completion percentage calculation
Modified paths:
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/tag/TranslatablePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageGroups.php
@@ -644,6 +644,35 @@
645645 return $rev->getText();
646646 }
647647
 648+ public function fillCollection( MessageCollection $messages ) {
 649+ parent::fillCollection( $messages );
 650+ $page = TranslatablePage::newFromTitle( $this->title );
 651+ $markedRevs = $page->getMarkedRevs( 'tp:mark' );
 652+
 653+ foreach ( $messages as $key => $m ) {
 654+ $rev = $page->getTransrev( $key .'/' . $messages->code );
 655+ if ( $rev === false ) {
 656+ $m->database = TRANSLATE_FUZZY . $m->database;
 657+ continue;
 658+ }
 659+ foreach ( $markedRevs as $r ) {
 660+ var_dump( $rev );
 661+ if ( $rev === $r->rt_revision ) break;
 662+ $changed = explode( '|', unserialize($r->rt_value) );
 663+
 664+ // Get a suitable section key
 665+ $parts = explode( '/', $key );
 666+ $ikey = $parts[count($parts)-1];
 667+
 668+ // If the section was changed, reduce the score
 669+ if ( in_array($ikey, $changed, true) ) {
 670+ $m->database = TRANSLATE_FUZZY . $m->database;
 671+ continue 2;
 672+ }
 673+ }
 674+ }
 675+ }
 676+
648677 }
649678
650679
Index: trunk/extensions/Translate/tag/TranslatablePage.php
@@ -246,7 +246,7 @@
247247 return $translate->getFullURL( $params );
248248 }
249249
250 - protected function getMarkedRevs( $tag ) {
 250+ public function getMarkedRevs( $tag ) {
251251 $db = wfGetDB( DB_SLAVE );
252252
253253 // Can this be done in one query?
@@ -315,8 +315,9 @@
316316 $total = 0;
317317
318318 foreach ( $collection as $key => $message ) {
319 - if ( !$message->translated() ) continue; // No score
320319
 320+ if ( $message->translation() === null ) continue; // No score
 321+
321322 $score = 1;
322323
323324 // Fuzzy halves score

Status & tagging log