From 35eb14f8378ff5a42cfcb153d21315436e273c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Tisza?= Date: Tue, 15 Apr 2014 02:43:17 +0000 Subject: [PATCH] Choose feedback survey based on user language Change-Id: Ia9d53b6a3caedecd05429e5285765b1c5098342e Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/420 --- resources/mmv/ui/mmv.ui.stripeButtons.js | 29 ++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/resources/mmv/ui/mmv.ui.stripeButtons.js b/resources/mmv/ui/mmv.ui.stripeButtons.js index 67c8afa6d..a2b35a8b1 100644 --- a/resources/mmv/ui/mmv.ui.stripeButtons.js +++ b/resources/mmv/ui/mmv.ui.stripeButtons.js @@ -187,12 +187,37 @@ } }; + /** + * Returns a link to a survey in the given language or null if that language is not supported + * @param {string|null} langcode + */ + SBP.getFeedbackSurveyBaseUrlForLanguage = function ( langcode ) { + var baseUrl = 'https://www.surveymonkey.com/s/media-viewer-1', + surveyTranslations = { ca: 1, hu: 1 }; + + langcode = langcode.split( /[_-]/ )[0]; // get rid of variants + if ( langcode === 'en') { + return baseUrl; + } else if ( surveyTranslations[langcode] ) { + return baseUrl + '-' + langcode; + } else { + return null; + } + }; + + /** + * Returns a link to a survey in the user language, or null if not supported + */ + SBP.getFeedbackSurveyBaseUrl = function () { + return this.getFeedbackSurveyBaseUrlForLanguage( mw.config.get( 'wgUserLanguage' ) ); + }; + /** * Checks if it is suitable to show a survey to the current user. */ SBP.shouldShowFeedbackSurvey = function () { return mw.config.get( 'wgMultimediaViewer' ).showSurvey && - mw.config.get( 'wgUserLanguage' ) === 'en'; + this.getFeedbackSurveyBaseUrl(); }; /** @@ -201,7 +226,7 @@ * @return {string} */ SBP.getFeedbackSurveyUrl = function () { - return 'https://www.surveymonkey.com/s/media-viewer-1?c=' + mw.config.get( 'wgDBname' ); + return this.getFeedbackSurveyBaseUrl() + '?c=' + mw.config.get( 'wgDBname' ); }; /**