Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/149801

Change subject: Dictionary, take language parameters so that we can show 
synonyms
......................................................................

Dictionary, take language parameters so that we can show synonyms

We do not have synonyms data at server, but make sure dictionary
card can take optional language pairs other than default sourceLanguage->
targetLanguage pair

Change-Id: Ie78f53403109bfc7284b86c428b963ab687e0a0e
---
M modules/tools/ext.cx.tools.dictionary.js
M modules/translation/ext.cx.translation.js
2 files changed, 13 insertions(+), 3 deletions(-)


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

diff --git a/modules/tools/ext.cx.tools.dictionary.js 
b/modules/tools/ext.cx.tools.dictionary.js
index ca012fb..1e0e78c 100644
--- a/modules/tools/ext.cx.tools.dictionary.js
+++ b/modules/tools/ext.cx.tools.dictionary.js
@@ -124,7 +124,14 @@
                this.onShow();
        };
 
-       DictionaryCard.prototype.start = function ( word ) {
+       /**
+        * @param {string} word
+        * @param {string} [sourceLanguage]
+        * @param {string} [targetLanguage]
+        */
+       DictionaryCard.prototype.start = function ( word, sourceLanguage, 
targetLanguage ) {
+               sourceLanguage = sourceLanguage || mw.cx.sourceLanguage;
+               targetLanguage = targetLanguage || mw.cx.targetLanguage;
                // Don't appear if there's nothing to translate
                if ( word === '' ) {
                        this.stop();
@@ -136,7 +143,7 @@
                // Show the source word and get a translation,
                // and don't appear if getting the translation fails
                this.$card.find( '.card__headword' ).text( word );
-               getTranslation( word, mw.cx.sourceLanguage, 
mw.cx.targetLanguage )
+               getTranslation( word, sourceLanguage, targetLanguage )
                        .done( $.proxy( this.showResult, this ) )
                        .fail( $.proxy( this.stop, this ) );
        };
diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 9f217ff..fc7bd44 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -148,6 +148,7 @@
                $section.find( 'img' ).adaptImage( mw.cx.targetLanguage );
                // Adapt references
                $sourceSection = $( '#' + $section.data( 'source' ) );
+
                if ( $.fn.adaptReferences ) { // This is an experimental feature
                        $section.find( '[typeof="mw:Extension/ref"]' 
).adaptReferences();
                }
@@ -172,7 +173,9 @@
                        var selection = window.getSelection().toString();
 
                        if ( selection ) {
-                               mw.hook( 'mw.cx.select.word' ).fire( selection 
);
+                               // In this case, user is interested in 
targetLanguage->targetLanguage
+                               // dictionary lookup. Or synonyms.
+                               mw.hook( 'mw.cx.select.word' ).fire( selection, 
mw.cx.targetLanguage, mw.cx.targetLanguage );
                        }
                } ) );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/149801
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie78f53403109bfc7284b86c428b963ab687e0a0e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to