r55135 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55134‎ | r55135 | r55136 >
Date:10:46, 16 August 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
Multiple fixes for the fuzzy action - not pefrect yet but should at least work
Modified paths:
  • /trunk/extensions/Translate/SpecialManageGroups.php (modified) (history)
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialManageGroups.php
@@ -355,7 +355,8 @@
356356 } elseif ( $action === 'ignore' ) {
357357 return array( 'translate-manage-import-ignore', $key );
358358 } elseif ( $action === 'fuzzy' ) {
359 - $title = self::makeTitle( $group, $key, $code );
 359+ $title = Title::makeTitleSafe( $group->getNamespace(), $key );
 360+ $comment = wfMsgForContentNoTrans( 'translate-manage-fuzzy-summary' );
360361 return $this->doFuzzy( $title, $message, $comment );
361362 } else {
362363 throw new MWException( "Unhandled action $action" );
@@ -368,8 +369,8 @@
369370
370371 protected function doImport( $title, $message, $comment, $user = null ) {
371372 $flags = EDIT_FORCE_BOT;
372 - $article = new Article( $title );
373 - $status = $article->doEdit( $message, $comment, $flags );
 373+ $article = new Article( $title );
 374+ $status = $article->doEdit( $message, $comment, $flags, false, $user );
374375 $success = $status->isOK();
375376
376377 if ( $success ) {
@@ -382,9 +383,11 @@
383384 }
384385
385386 protected function doFuzzy( $title, $message, $comment ) {
 387+ global $wgUser;
 388+
386389 $dbw = wfGetDB( DB_MASTER );
387390 $titleText = $title->getDBKey();
388 - $condArray = array(
 391+ $conds = array(
389392 'page_namespace' => $title->getNamespace(),
390393 'page_latest=rev_id',
391394 'rev_text_id=old_id',
@@ -403,26 +406,26 @@
404407 foreach ( $rows as $row ) {
405408 $ttitle = Title::makeTitle( $row->page_namespace, $row->page_title );
406409
407 - $changed[] = $this->doImport(
408 - $ttitle,
409 - TRANSLATE_FUZZY . Revision::getRevisionText( $row ),
410 - $comment,
411 - $fuzzybot
412 - );
 410+ // Avoid double-fuzzying
 411+ $text = Revision::getRevisionText( $row );
 412+ $text = str_replace( TRANSLATE_FUZZY, '', $text );
 413+ $text = TRANSLATE_FUZZY . $text;
413414
 415+ $changed[] = $this->doImport( $ttitle, $text, "[{$wgUser->getName()}] " . $comment, $fuzzybot );
414416 if ( $this->checkProcessTime() ) break;
415417
416418 }
417419
418 - if ( count($changed) === count($rows) ) {
419 - $comment = wfMsgForContentNoTrans( 'translate-manage-import-summary' );
420 - $changed[] = $this->doImport( $title, $message, $comment );
 420+ if ( count($changed) === $rows->numRows() ) {
 421+ $comment = "[{$wgUser->getName()}] " . wfMsgForContentNoTrans( 'translate-manage-import-summary' );
 422+ $title = Title::makeTitleSafe( $title->getNamespace, $title->getPrefixedDbKey() . '/en' );
 423+ $changed[] = $this->doImport( $title, $message, $comment, $fuzzybot );
421424 }
422425
423426 $text = '';
424427 foreach ( $changed as $c ) {
425428 $key = array_shift( $c );
426 - $text = "* " . wfMsgExt( $key, array(), $c );
 429+ $text .= "* " . wfMsgExt( $key, array(), $c ) . "\n";
427430 }
428431
429432 return array( 'translate-manage-import-fuzzy',
Index: trunk/extensions/Translate/Translate.i18n.php
@@ -267,6 +267,7 @@
268268 'translate-manage-import-summary' => 'Importing a new version from external source',
269269 'translate-manage-conflict-summary' => 'Importing a new version from external source.
270270 Please check.',
 271+ 'translate-manage-fuzzy-summary' => 'The definition has changed',
271272 'translate-manage-import-fuzzy' => 'Importing and fuzzying: $1',
272273
273274 'translate-manage-import-done' => 'All done!',

Status & tagging log