jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/377707 )
Change subject: CX1 MT: Unwrap the MT output if wrapped by legacy cxserver api ...................................................................... CX1 MT: Unwrap the MT output if wrapped by legacy cxserver api cxserver /mt api won't wrap the output in unwanted <div> tag since https://gerrit.wikimedia.org/r/#/c/374520/ Make the unwrapping conditional by checking the root tag of the MT output recieved. Change-Id: I014ced5bc306654053cf47c8cdfe4384ce90bdfb --- M modules/tools/ext.cx.tools.mt.js 1 file changed, 15 insertions(+), 8 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/tools/ext.cx.tools.mt.js b/modules/tools/ext.cx.tools.mt.js index 44eacee..387a3a9 100644 --- a/modules/tools/ext.cx.tools.mt.js +++ b/modules/tools/ext.cx.tools.mt.js @@ -346,19 +346,26 @@ } else { this.getTranslatedSection( this.$sourceSection ) .done( function ( translation ) { + var $translation; if ( !translation || !translation.length ) { return self.useSource(); } + $translation = $( translation ); + if ( $translation.is( 'div' ) && !$translation.attr( 'id' ) ) { + // Translation is wrapped in <div> tag. And it is not part of section, + // which will have at least id attribute. + // Legacy cxserver behavior. Unwrap it. + $translation = $translation.children(); + } + $translation.attr( { + id: 'cx' + self.sourceId, + 'data-source': self.sourceId, + 'data-cx-state': 'mt', + 'data-cx-mt-provider': self.provider + } ); // Use fresh copy - self.replaceSectionWith( $( translation ) - .children() - .attr( { - id: 'cx' + self.sourceId, - 'data-source': self.sourceId, - 'data-cx-state': 'mt', - 'data-cx-mt-provider': self.provider - } ) ); + self.replaceSectionWith( $translation ); } ).fail( function () { return self.useSource(); } ).always( function () { -- To view, visit https://gerrit.wikimedia.org/r/377707 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I014ced5bc306654053cf47c8cdfe4384ce90bdfb Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Catrope <r...@wikimedia.org> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits