Survey language setting from survey question | XM Community
Solved

Survey language setting from survey question

  • 17 September 2018
  • 9 replies
  • 859 views

Hello,

I'm running a multi-country survey, which includes certain dual-language markets (namely English & Arabic).

As this study goes out through a survey panel, I need to give the option to respondents to select their language on the first question of the survey, and then have the survey switch to whatever language they selected.

Please note:
- Enabling the language drop-down is not an option as respondents will be able to see all the available languages, across all the markets that I'm running the survey in
- I tried using Survey Flow where after respondents would choose the language I added a Survey close that re-open the survey link with the appropriate Q_Language operator added. However, as the panel provider is embedding their user ID to the initial survey link and this is not passed to the redirected link, this is not a viable option either

Any suggestions on how the survey language can be controlled through the first survey question are more than welcome!

Many thanks in advance,

George
icon

Best answer by MohammedAli_Rajapkar 17 September 2018, 16:13

View original

9 replies

Userlevel 7
Badge +33
Have you tried your own question with languages and apply branching on each language block or survey.
Userlevel 7
Badge +20
Hi @GeorgeUAE

You can try adding below code... If we know the respondent preferred language then we can remove the additional language from the drop-down.

Like below, if I have 4 languages in my project such as "English, Arabic, French and German then I will check if "Q_Language" (language embedded data) is Arabic (AR) then remove the additional language from the drop-down apart from English...(note: whichever language you want to remove, you can do it by adding the "remove()" line with appropriate language code.

I will add the below code in the header under look & feel tab Advanced section:
https://www.qualtrics.com/support/survey-platform/survey-module/look-feel/advanced-look-feel-settings/#InsertingAHeader

within script tag
var language identifier = "${e://Field/Q_Language}";
if ( languageidentifier == "AR")
{
jQuery("#Q_lang ").find("[value=DE]").remove();
jQuery("#Q_lang ").find("[value=FR]").remove();
}

___________________________________________________________________________________
And, if you just want to show the language selection drop-down on first question only then you will have to insert below code in the header part:

within script tag:
jQuery("div[class='LanguageSelectorContainer']").hide();
jQuery("select[name='Q_lang']").hide();

And then on the first question of the survey, you will have to add below code under JavaScript section in "onReady" part

jQuery("div[class='LanguageSelectorContainer']").show();
jQuery("select[name='Q_lang']").show();

var language identifier = "${e://Field/Q_Language}";
if ( languageidentifier == "AR")
{
jQuery("#Q_lang ").find("[value=DE]").remove();
jQuery("#Q_lang ").find("[value=FR]").remove();
}
Userlevel 7
Badge +27
@GeorgeUAE ,

You can hide the language selector on all the pages by adding this script to your header:
```
<script>
Qualtrics.SurveyEngine.addOnload(function() { jQuery(".LanguageSelectorContainer").hide(); });
</script>
```
If you set a "country" embedded variable through a url parameter, then you can show the language selector with only the applicable languages for the country on the first page and have a descriptive text question instructing the respondent to pick their language from the drop down.

Use JavaScript attached to your descriptive text question on the first page to define an object with the languages that apply to each country similar to this:
```
Qualtrics.SurveyEngine.addOnReady(function() {
var countries = { //define languages for each country
US: ["EN", "ES"],
CA: ["EN", "FR-CA"],
MX: ["EN", "ES"]
};
jQuery(".LanguageSelectorContainer").show(); //show language selector on this page
jQuery("#Q_lang option").hide(); //hide all languages
jQuery.each(countries["${e://Field/country}"], function(index, value) { jQuery("#Q_lang option[value="+value+"]").show(); }); //show applicable languages
});
```
Thank you all for your suggestions. Hiding the language options and enabling the dropdown to appear only on the first question did the trick. 😀
Badge +5
@TomG Is there a way to make the javascript codes you've provided work on mobile? I'm able to get the language selector to display certain languages depending on the country code on my desktop, but all the languages are displayed when I try selecting the language using iPhone. I've got javascript enabled on my iPhone.
Userlevel 7
Badge +27
> @Amos_ said:
> @TomG Is there a way to make the javascript codes you've provided work on mobile? I'm able to get the language selector to display certain languages depending on the country code on my desktop, but all the languages are displayed when I try selecting the language using iPhone. I've got javascript enabled on my iPhone.

Safari doesn't support hiding of select options. The way around it would be to hide the Qualtrics dropdown and add your own dropdown with just the options you want with a handler that updates the Qualtrics dropdown selection anytime something in your dropdown is selected.
Badge +5
Thanks for the suggestion @TomG !
Badge
> And, if you just want to show the language selection drop-down on first question only then you will have to insert below code in the header part:
>
> within script tag:
> jQuery("div[class='LanguageSelectorContainer']").hide();
> jQuery("select[name='Q_lang']").hide();
>
> And then on the first question of the survey, you will have to add below code under JavaScript section in "onReady" part
>
> jQuery("div[class='LanguageSelectorContainer']").show();
> jQuery("select[name='Q_lang']").show();
>
> var language identifier = "${e://Field/Q_Language}";
> if ( languageidentifier == "AR")
> {
> jQuery("#Q_lang ").find("[value=DE]").remove();
> jQuery("#Q_lang ").find("[value=FR]").remove();
> }
>

@tomg I tried this but I received an "Invalid JavaScript! You cannot save until you fix all errors: Unexpected identifier" error when I entered the code under JavaScript in "onReady" section. Can you tell me where I'm going wrong?

Here is what I put in:

Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery("div[class='LanguageSelectorContainer']").show();
jQuery("select[name='Q_lang']").show();

var language identifier = "${e://Field/Q_Language}";
if ( languageidentifier == "AR")
{
jQuery("#Q_lang ").find("[value=DE]").remove();
jQuery("#Q_lang ").find("[value=FR]").remove();
}


});
Userlevel 7
Badge +27
@TiffanyY - Try removing the single quotes around LanguageSelectorContainer and Q_lang.

Leave a Reply