jenkins-bot has submitted this change and it was merged.
Change subject: Fix the appearance of translatable pages diffs in TUX
......................................................................
Fix the appearance of translatable pages diffs in TUX
1. Update the saving hook to save the correct revision ID:
the translation unit's ID instead of the whole page's ID.
2. Update the TranslationHelpers for the pre-TUX editor:
merge the function for translatable pages diff with
the regular page diff.
Done with help from Niklas.
Change-Id: Ie976c62a8d0f1b3217f7c9b29ac45c8bd89f9ccf
---
M TranslateEditAddons.php
M tag/PageTranslationHooks.php
M utils/TranslationHelpers.php
3 files changed, 1 insertion(+), 90 deletions(-)
Approvals:
Nikerabbit: Looks good to me, approved
jenkins-bot: Verified
diff --git a/TranslateEditAddons.php b/TranslateEditAddons.php
index 44e53e5..5c59f7f 100644
--- a/TranslateEditAddons.php
+++ b/TranslateEditAddons.php
@@ -442,10 +442,6 @@
}
$group = $handle->getGroup();
- if ( $group instanceof WikiPageMessageGroup ) {
- // WikiPageMessageGroup has different method
- return true;
- }
$title = $handle->getTitle();
$name = $handle->getKey() . '/' . $group->getSourceLanguage();
diff --git a/tag/PageTranslationHooks.php b/tag/PageTranslationHooks.php
index 5423138..3649988 100644
--- a/tag/PageTranslationHooks.php
+++ b/tag/PageTranslationHooks.php
@@ -116,14 +116,6 @@
// Finally we know the title and can construct a Translatable
page
$page = TranslatablePage::newFromTitle( $group->getTitle() );
- // Add a tracking mark
- if ( $revision !== null ) {
- /**
- * @var Revision $revision
- */
- self::addSectionTag( $title, $revision->getId(),
$page->getMarkedTag() );
- }
-
// Update the target translation page
if ( !$handle->isDoc() ) {
$code = $handle->getCode();
@@ -131,25 +123,6 @@
}
return true;
- }
-
- protected static function addSectionTag( Title $title, $revision,
$pageRevision ) {
- if ( $pageRevision === null ) {
- throw new MWException( 'Page revision is null' );
- }
-
- $dbw = wfGetDB( DB_MASTER );
-
- $conds = array(
- 'rt_page' => $title->getArticleID(),
- 'rt_type' => RevTag::getType( 'tp:transver' ),
- 'rt_revision' => $revision
- );
- $dbw->delete( 'revtag', $conds, __METHOD__ );
-
- $conds['rt_value'] = $pageRevision;
-
- $dbw->insert( 'revtag', $conds, __METHOD__ );
}
public static function updateTranslationPage( TranslatablePage $page,
diff --git a/utils/TranslationHelpers.php b/utils/TranslationHelpers.php
index 8481429..d6d423e 100644
--- a/utils/TranslationHelpers.php
+++ b/utils/TranslationHelpers.php
@@ -223,7 +223,6 @@
'other-languages' => array( $this,
'getOtherLanguagesBox' ),
'translation-memory' => array( $this,
'getSuggestionBox' ),
'translation-diff' => array( $this, 'getPageDiff' ),
- 'page-translation' => array( $this,
'getTranslationPageDiff' ),
'separator' => array( $this, 'getSeparatorBox' ),
'documentation' => array( $this, 'getDocumentationBox'
),
'definition' => array( $this, 'getDefinitionBox' ),
@@ -1027,7 +1026,7 @@
$title = $this->handle->getTitle();
$key = $this->handle->getKey();
- if ( $group instanceof WikiPageMessageGroup ||
!$title->exists() ) {
+ if ( !$title->exists() ) {
return null;
}
@@ -1060,63 +1059,6 @@
}
$oldtext = $oldrev->getText();
$newtext = Revision::newFromTitle( $definitionTitle,
$latestRevision )->getText();
-
- if ( $oldtext === $newtext ) {
- return null;
- }
-
- $diff = new DifferenceEngine;
- if ( method_exists( 'DifferenceEngine', 'setTextLanguage' ) ) {
- $diff->setTextLanguage(
$this->group->getSourceLanguage() );
- }
- $diff->setText( $oldtext, $newtext );
- $diff->setReducedLineNumbers();
- $diff->showDiffStyle();
-
- return $diff->getDiff(
- wfMessage( 'tpt-diff-old' )->escaped(),
- wfMessage( 'tpt-diff-new' )->escaped()
- );
- }
-
- protected function getTranslationPageDiff() {
-
- global $wgEnablePageTranslation;
-
- if ( !$wgEnablePageTranslation ) {
- return null;
- }
-
- $this->mustBeKnownMessage();
- if ( !$this->group instanceof WikiPageMessageGroup ) {
- return null;
- }
-
- // Shortcuts
- $code = $this->handle->getCode();
- $key = $this->handle->getKey();
-
- // @todo Encapsulate somewhere
- $page = TranslatablePage::newFromTitle(
$this->group->getTitle() );
- $rev = $page->getTransRev( "$key/$code" );
- $latest = $page->getMarkedTag();
- if ( $rev === $latest ) {
- return null;
- }
-
- $oldpage = TranslatablePage::newFromRevision(
$this->group->getTitle(), $rev );
- $oldtext = $newtext = null;
- foreach ( $oldpage->getParse()->getSectionsForSave() as
$section ) {
- if ( $this->group->getTitle()->getPrefixedDBKey() . '/'
. $section->id === $key ) {
- $oldtext = $section->getTextForTrans();
- }
- }
-
- foreach ( $page->getParse()->getSectionsForSave() as $section )
{
- if ( $this->group->getTitle()->getPrefixedDBKey() . '/'
. $section->id === $key ) {
- $newtext = $section->getTextForTrans();
- }
- }
if ( $oldtext === $newtext ) {
return null;
--
To view, visit https://gerrit.wikimedia.org/r/52035
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie976c62a8d0f1b3217f7c9b29ac45c8bd89f9ccf
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits