jenkins-bot has submitted this change and it was merged.
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(-)
Approvals:
Amire80: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/tools/ext.cx.tools.dictionary.js
b/modules/tools/ext.cx.tools.dictionary.js
index 4b50dd6..fb17781 100644
--- a/modules/tools/ext.cx.tools.dictionary.js
+++ b/modules/tools/ext.cx.tools.dictionary.js
@@ -127,7 +127,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();
@@ -143,7 +150,7 @@
// Try to get a translation.
// Don't appear if getting the translation fails.
- 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: merged
Gerrit-Change-Id: Ie78f53403109bfc7284b86c428b963ab687e0a0e
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits