r110229 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110228‎ | r110229 | r110230 >
Date:09:25, 29 January 2012
Author:nikerabbit
Status:ok
Tags:i18nreview, miscextensions 
Comment:
The last missing piece: working updater for tm
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateHooks.php (modified) (history)
  • /trunk/extensions/Translate/utils/TTMServer.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.php
@@ -122,6 +122,7 @@
123123
124124 // Translation memory updates
125125 $wgHooks['Translate:newTranslation'][] = 'TranslationMemoryUpdater::update';
 126+$wgHooks['Translate:newTranslation'][] = 'TranslateHooks::updateTM';
126127
127128 // Translation display related
128129 $wgHooks['ArticleContentOnDiff'][] = 'TranslateEditAddons::displayOnDiff';
Index: trunk/extensions/Translate/TranslateHooks.php
@@ -385,5 +385,15 @@
386386 $output = Html::element( 'a', $a, $linktext );
387387 return $parser->insertStripItem( $output, $parser->mStripState );
388388 }
 389+
 390+ /**
 391+ * Shovels the new translation into TTMServer.
 392+ * Hook: Translate:newTranslation
 393+ */
 394+ public static function updateTM( MessageHandle $handle, $revision, $text, User $user ) {
 395+ TTMServer::primary()->update( $handle, $text );
 396+ return true;
 397+ }
 398+
389399 }
390400
Index: trunk/extensions/Translate/utils/TTMServer.php
@@ -116,11 +116,10 @@
117117
118118 // Insert the new translation
119119 $row = $deleteConds + array(
120 - 'text' => $targetText,
 120+ 'tmt_text' => $targetText,
121121 );
122122
123 - $uniqueIndex = array( 'tmt_sid', 'tmt_lang' );
124 - $dbw->insert( 'translate_tmt', array( $uniqueIndex ), $row, __METHOD__ );
 123+ $dbw->insert( 'translate_tmt', $row, __METHOD__ );
125124
126125 return true;
127126 }

Status & tagging log