Index: trunk/extensions/Translate/TranslateEditAddons.php |
— | — | @@ -302,7 +302,7 @@ |
303 | 303 | $rev = $revision->getID(); |
304 | 304 | } |
305 | 305 | |
306 | | - // Add the ready tag |
| 306 | + // <fuzzy tag |
307 | 307 | $dbw = wfGetDB( DB_MASTER ); |
308 | 308 | |
309 | 309 | $id = $dbw->selectField( 'revtag_type', 'rtt_id', array( 'rtt_name' => 'fuzzy' ), __METHOD__ ); |
— | — | @@ -319,7 +319,27 @@ |
320 | 320 | if ( $fuzzy !== false ) { |
321 | 321 | $dbw->insert( 'revtag', $conds, __METHOD__ ); |
322 | 322 | } |
| 323 | + // fuzzy> |
323 | 324 | |
| 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 | + |
324 | 344 | return true; |
325 | 345 | } |
326 | 346 | |
Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -112,7 +112,8 @@ |
113 | 113 | $all = array( |
114 | 114 | 'other-languages' => array( $this, 'getOtherLanguagesBox' ), |
115 | 115 | 'translation-memory' => array( $this, 'getSuggestionBox' ), |
116 | | - 'page-translation' => array( $this, 'getPageDiff' ), |
| 116 | + 'translation-diff' => array( $this, 'getPageDiff' ), |
| 117 | + 'page-translation' => array( $this, 'getTranslationPageDiff' ), |
117 | 118 | 'separator' => array( $this, 'getSeparatorBox' ), |
118 | 119 | 'documenation' => array( $this, 'getDocumentationBox' ), |
119 | 120 | 'definition' => array( $this, 'getDefinitionBox' ), |
— | — | @@ -495,6 +496,46 @@ |
496 | 497 | } |
497 | 498 | |
498 | 499 | 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() { |
499 | 540 | global $wgEnablePageTranslation; |
500 | 541 | if ( !$wgEnablePageTranslation ) return null; |
501 | 542 | if ( !$this->group instanceof WikiPageMessageGroup ) return null; |