jenkins-bot has submitted this change and it was merged.
Change subject: Do not attempt adding orphan section unless source article is
old revision
......................................................................
Do not attempt adding orphan section unless source article is old revision
We are attempting orphan section fitting in lastest revision and if that
fails we load old revision of source.
We are changing that behavior. The orphan section fitting will be attempted
only on old source revision.
So the improvised translation reload steps are:
1. Try to find matching source section ids and restore translation against it
2. Try to find matching sequence Id in source and restore translation against it
3. Load the source article's revision that was used for the translation. and
attempt
step #1 and #2
4. If the source article is old revision, add orphan sections in translation
column
when #1 and #2 failed.
Change-Id: I7705279068a623c4e367d696403138c04334fbca
---
M modules/translation/ext.cx.translation.loader.js
M tests/qunit/translation/ext.cx.translation.loader.test.js
2 files changed, 14 insertions(+), 3 deletions(-)
Approvals:
KartikMistry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/translation/ext.cx.translation.loader.js
b/modules/translation/ext.cx.translation.loader.js
index 31a92bb..6a7b493 100644
--- a/modules/translation/ext.cx.translation.loader.js
+++ b/modules/translation/ext.cx.translation.loader.js
@@ -17,6 +17,7 @@
this.$sourceColumn = null;
this.$translationColumn = null;
this.disabled = false;
+ this.oldRevision = false;
}
/**
@@ -102,7 +103,12 @@
self.restore();
mw.hook( 'mw.cx.draft.restored' ).fire();
if ( self.translation.sourceRevisionId !==
mw.cx.sourceRevision ) {
+ // Show a message to translator that we
loaded an older revision of
+ // source article.
self.showOldRevisionWarning();
+ // Since we are using older revision,
use agressive section restore
+ // algorithm.
+ self.oldRevision = true;
}
} );
}, function ( errorCode, details ) {
@@ -200,7 +206,7 @@
if ( !$restoredSection ) {
mw.log( 'Source section not found for ' +
sourceSectionId );
// Insert right after last matched section if
possible
- if ( $lastRestoredSection &&
$lastRestoredSection.length ) {
+ if ( this.oldRevision && $lastRestoredSection
&& $lastRestoredSection.length ) {
$lastRestoredSection =
this.addOprhanTranslationUnit(
sourceSectionId,
$lastRestoredSection, 'after'
);
@@ -213,6 +219,10 @@
$lastRestoredSection = $restoredSection;
// As a last resort, if we did not add orphans
immediately, add them
// now before this section.
+ if ( !this.oldRevision ) {
+ // Dont use orphan sections unless we
are using old source article
+ continue;
+ }
for ( i = 0; i < orphans.length; i++ ) {
$lastRestoredSection =
this.addOprhanTranslationUnit( orphans[ i ], $lastRestoredSection );
if ( $restoredSection &&
$restoredSection.length ) {
@@ -223,7 +233,7 @@
}
}
- if ( orphans.length ) {
+ if ( orphans.length && !this.oldRevision ) {
mw.log( 'Draft restoration failed. Loading older
revision.' );
window.location = mw.cx.siteMapper.getCXUrl(
mw.cx.sourceTitle,
diff --git a/tests/qunit/translation/ext.cx.translation.loader.test.js
b/tests/qunit/translation/ext.cx.translation.loader.test.js
index 24055b7..1a3910a 100644
--- a/tests/qunit/translation/ext.cx.translation.loader.test.js
+++ b/tests/qunit/translation/ext.cx.translation.loader.test.js
@@ -52,7 +52,8 @@
QUnit.test( 'Translation daft restore test', function ( assert ) {
var i;
QUnit.expect( tests.length );
-
+ // Without old revision flag set true, orphan sections wont get
added.
+ this.translatonLoader.oldRevision = true;
for ( i = 0; i < tests.length; i++ ) {
this.translatonLoader.translationUnits =
this.translatonLoader.getTranslationUnits( tests[ i ].draft );
this.translatonLoader.$sourceColumn = $( tests[ i
].source );
--
To view, visit https://gerrit.wikimedia.org/r/275752
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7705279068a623c4e367d696403138c04334fbca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: KartikMistry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits