r66837 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66836‎ | r66837 | r66838 >
Date:17:04, 24 May 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Definition revision tracking for all translations
Modified paths:
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslationHelpers.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -302,7 +302,7 @@
303303 $rev = $revision->getID();
304304 }
305305
306 - // Add the ready tag
 306+ // <fuzzy tag
307307 $dbw = wfGetDB( DB_MASTER );
308308
309309 $id = $dbw->selectField( 'revtag_type', 'rtt_id', array( 'rtt_name' => 'fuzzy' ), __METHOD__ );
@@ -319,7 +319,27 @@
320320 if ( $fuzzy !== false ) {
321321 $dbw->insert( 'revtag', $conds, __METHOD__ );
322322 }
 323+ // fuzzy>
323324
 325+ // Diffs for changed messages
 326+ if ( $group instanceof WikiPageMessageGroup ) return true;
 327+ $definitionTitle = Title::makeTitleSafe( $title->getNamespace(), "$key/en" );
 328+ if ( $definitionTitle && $definitionTitle->exists() ) {
 329+ $definitionRevision = $definitionTitle->getLatestRevID();
 330+
 331+ $id = $dbw->selectField( 'revtag_type', 'rtt_id',
 332+ array( 'rtt_name' => 'tp:transver' ), __METHOD__ );
 333+
 334+ $conds = array(
 335+ 'rt_page' => $title->getArticleId(),
 336+ 'rt_type' => $id,
 337+ 'rt_revision' => $rev,
 338+ );
 339+ $dbw->delete( 'revtag', $conds, __METHOD__ );
 340+ $conds['rt_value'] = $definitionRevision;
 341+ $dbw->insert( 'revtag', $conds, __METHOD__ );
 342+ }
 343+
324344 return true;
325345 }
326346
Index: trunk/extensions/Translate/utils/TranslationHelpers.php
@@ -112,7 +112,8 @@
113113 $all = array(
114114 'other-languages' => array( $this, 'getOtherLanguagesBox' ),
115115 'translation-memory' => array( $this, 'getSuggestionBox' ),
116 - 'page-translation' => array( $this, 'getPageDiff' ),
 116+ 'translation-diff' => array( $this, 'getPageDiff' ),
 117+ 'page-translation' => array( $this, 'getTranslationPageDiff' ),
117118 'separator' => array( $this, 'getSeparatorBox' ),
118119 'documenation' => array( $this, 'getDocumentationBox' ),
119120 'definition' => array( $this, 'getDefinitionBox' ),
@@ -495,6 +496,46 @@
496497 }
497498
498499 protected function getPageDiff() {
 500+ if ( $this->group instanceof WikiPageMessageGroup ) return null;
 501+
 502+ // Shortcuts
 503+ $code = $this->targetLanguage;
 504+ $key = $this->page;
 505+
 506+ $definitionTitle = Title::makeTitleSafe( $this->title->getNamespace(), "$key/en" );
 507+ if ( !$definitionTitle || !$definitionTitle->exists() ) {
 508+ return null;
 509+ }
 510+
 511+ $db = wfGetDB( DB_MASTER );
 512+ $id = $db->selectField( 'revtag_type', 'rtt_id',
 513+ array( 'rtt_name' => 'tp:transver' ), __METHOD__ );
 514+
 515+ $conds = array(
 516+ 'rt_page' => $this->title->getArticleId(),
 517+ 'rt_type' => $id,
 518+ 'rt_revision' => $this->title->getLatestRevID(),
 519+ );
 520+
 521+ $latestRevision = $definitionTitle->getLatestRevID();
 522+ $translationRevision = $db->selectField( 'revtag', 'rt_value', $conds, __METHOD__ );
 523+ var_dump($translationRevision);
 524+
 525+ if ( $translationRevision === false ) return null;
 526+
 527+ $oldtext = Revision::newFromTitle( $definitionTitle, $translationRevision )->getText();
 528+ $newtext = Revision::newFromTitle( $definitionTitle, $latestRevision )->getText();
 529+
 530+ if ( $oldtext === $newtext ) return null;
 531+
 532+ $diff = new DifferenceEngine;
 533+ $diff->setText( $oldtext, $newtext );
 534+ $diff->setReducedLineNumbers();
 535+ $diff->showDiffStyle();
 536+ return $diff->getDiff( wfMsgHtml( 'tpt-diff-old' ), wfMsgHtml( 'tpt-diff-new' ) );
 537+ }
 538+
 539+ protected function getTranslationPageDiff() {
499540 global $wgEnablePageTranslation;
500541 if ( !$wgEnablePageTranslation ) return null;
501542 if ( !$this->group instanceof WikiPageMessageGroup ) return null;

Status & tagging log