Santhosh has uploaded a new change for review. ( 
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, 13 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/07/377707/1

diff --git a/modules/tools/ext.cx.tools.mt.js b/modules/tools/ext.cx.tools.mt.js
index 44eacee..03449fc 100644
--- a/modules/tools/ext.cx.tools.mt.js
+++ b/modules/tools/ext.cx.tools.mt.js
@@ -346,19 +346,24 @@
                } else {
                        this.getTranslatedSection( this.$sourceSection )
                                .done( function ( translation ) {
+                                       var $translation;
                                        if ( !translation || 
!translation.length ) {
                                                return self.useSource();
                                        }
 
+                                       $translation = $( translation );
+                                       if ( $translation.is( 'div' ) && 
!self.$sourceSection.is( 'div' ) ) {
+                                               // Translation is wrapped in 
<div> tag. 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: newchange
Gerrit-Change-Id: I014ced5bc306654053cf47c8cdfe4384ce90bdfb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to