Choose feedback survey based on user language

Change-Id: Ia9d53b6a3caedecd05429e5285765b1c5098342e
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/420
This commit is contained in:
Gergő Tisza 2014-04-15 02:43:17 +00:00
parent 201f97cf28
commit 35eb14f837

View file

@ -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. * Checks if it is suitable to show a survey to the current user.
*/ */
SBP.shouldShowFeedbackSurvey = function () { SBP.shouldShowFeedbackSurvey = function () {
return mw.config.get( 'wgMultimediaViewer' ).showSurvey && return mw.config.get( 'wgMultimediaViewer' ).showSurvey &&
mw.config.get( 'wgUserLanguage' ) === 'en'; this.getFeedbackSurveyBaseUrl();
}; };
/** /**
@ -201,7 +226,7 @@
* @return {string} * @return {string}
*/ */
SBP.getFeedbackSurveyUrl = function () { 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' );
}; };
/** /**