http://www.mediawiki.org/wiki/Special:Code/MediaWiki/68605
Revision: 68605 Author: nikerabbit Date: 2010-06-26 12:50:50 +0000 (Sat, 26 Jun 2010) Log Message: ----------- Fixed translation completion percentage calculation bug. This was triggered when new the "do not mark translations outdated" switch was used. The calculation would however see that translation was made against an older version and added 20% penalty for it. The fix is to consider the number of changes since the version the translation was made against only if the message is currently marked outdated. Modified Paths: -------------- trunk/extensions/Translate/tag/SpecialPageTranslation.php trunk/extensions/Translate/tag/TranslatablePage.php Modified: trunk/extensions/Translate/tag/SpecialPageTranslation.php =================================================================== --- trunk/extensions/Translate/tag/SpecialPageTranslation.php 2010-06-26 12:10:47 UTC (rev 68604) +++ trunk/extensions/Translate/tag/SpecialPageTranslation.php 2010-06-26 12:50:50 UTC (rev 68605) @@ -487,7 +487,8 @@ $dbw->delete( 'translate_sections', array( 'trs_page' => $page->getTitle()->getArticleId() ), __METHOD__ ); $ok = $dbw->insert( 'translate_sections', $inserts, __METHOD__ ); - // Stores the names of changed sections in the database. Not currently used for anything. + /* Stores the names of changed sections in the database. + * Used for calculating completion percentages for outdated messages */ $page->addMarkedTag( $newrevision, $changed ); $this->addFuzzyTags( $page, $changed ); Modified: trunk/extensions/Translate/tag/TranslatablePage.php =================================================================== --- trunk/extensions/Translate/tag/TranslatablePage.php 2010-06-26 12:10:47 UTC (rev 68604) +++ trunk/extensions/Translate/tag/TranslatablePage.php 2010-06-26 12:50:50 UTC (rev 68605) @@ -478,10 +478,9 @@ $memcKey = wfMemcKey( 'pt', 'status', $this->getTitle()->getPrefixedText() ); $cache = $wgMemc->get( $memcKey ); - if ( !$force && $wgRequest->getText( 'action' ) !== 'purge' ) { - if ( is_array( $cache ) ) { - return $cache; - } + $force = $force || $wgRequest->getText( 'action' ) === 'purge'; + if ( !$force && is_array( $cache ) ) { + return $cache; } $titles = $this->getTranslationPages(); @@ -532,21 +531,24 @@ // Fuzzy halves score if ( $message->hasTag( 'fuzzy' ) ) { $score *= 0.5; - } - // Reduce 20% for every newer revision than what is translated against - $rev = $this->getTransrev( $key . '/' . $collection->code ); - foreach ( $markedRevs as $r ) { - if ( $rev === $r->rt_revision ) break; - $changed = explode( '|', unserialize( $r->rt_value ) ); + /* Reduce 20% for every newer revision than what is translated against. + * This is inside fuzzy clause, because there might be silent changes + * which we don't want to decrease the translation percentage. + */ + $rev = $this->getTransrev( $key . '/' . $collection->code ); + foreach ( $markedRevs as $r ) { + if ( $rev === $r->rt_revision ) break; + $changed = explode( '|', unserialize( $r->rt_value ) ); - // Get a suitable section key - $parts = explode( '/', $key ); - $ikey = $parts[count( $parts ) - 1]; + // Get a suitable section key + $parts = explode( '/', $key ); + $ikey = $parts[count( $parts ) - 1]; - // If the section was changed, reduce the score - if ( in_array( $ikey, $changed, true ) ) { - $score *= 0.8; + // If the section was changed, reduce the score + if ( in_array( $ikey, $changed, true ) ) { + $score *= 0.8; + } } } $total += $score; _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs