How to set the language according to the selected country in a question? | XM Community
Question

How to set the language according to the selected country in a question?

  • 5 March 2019
  • 6 replies
  • 108 views

Userlevel 1
Badge +3
Hello!

Can I fix the language of a survey according to the selected country in the initial questions of the survey?

I have a survey for 7 countries and it includes images with phrases on the languages of those particular countries (through branches). So, I need to make sure that the person that responds the questionnaire really understands the language of the country they selected. I can not use more branches, as the survey is already huge and that will difficult the data analysis later on. I also can not use other links to different surveys, as we are using panel respondents.

Is there a code that I can implement inside the survey to force respondents to see que questionnaire in the language of the selected country and not their browser language?

Thank you

6 replies

Userlevel 7
Badge +27
Hi @ecd921

As mentioned in the other thread , I looked into it. the code is working fine as it selects the language from the language select box. But the problem is the language is not being changes as earlier it used to change . I am not sure what changes they have made. I Couldn't find any workaround as of now for this problem but will try to inform here if i find any.

Regards,
Nihal
Userlevel 1
Badge +3
Thank you Nihal. I also will try to look into it.

Best regards,

Emilia
Userlevel 6
Badge +11
Hi, @ecd921! I know you posted looking for a custom code solution, but I just wanted to mention that we do have a built-in transaltion tool that you may find useful. Feel free to reach out to our Support Team if you have any further questions!
Userlevel 6
Badge +6
After you have your translation input, you can use branch logic to set the language of the survey as embedded data then pick that up on the very next page using JavaScript:

!

```
Qualtrics.SurveyEngine.addOnReady(function() {
var lang = Qualtrics.SurveyEngine.getEmbeddedData('SelectedLanguage');
jQuery('#Q_lang').val(lang);
jQuery('#Q_lang').trigger("change");
});
```

Working Example: https://qualtricssfi.az1.qualtrics.com/jfe/preview/SV_1S9Vsd1SAm5fNc1?Q_SurveyVersionID=current&Q_CHL=preview

QSF attached

Hi mattyb513 ,
Hoping you could help me out...I've tried replicating your solution above; but after the user selects a language (In the block "Language selection"), items in the next block ("Introduction") are not being displayed according to that selected language. Survey flow and CSS for the next item posted below. Any thoughts as to what the issue might be?
Thanks,
Brian
image.pngJS in the first item of the block that follows the block containing the 'language' item:
Qualtrics.SurveyEngine.addOnReady(function() {
  var lang = Qualtrics.SurveyEngine.getEmbeddedData('SelectedLanguage');
  jQuery("#Q_lang").val(lang);
  jQuery("#Q_lang").trigger("change");
});

Userlevel 2
Badge +6

https://community.qualtrics.com/XMcommunity/discussion/comment/33553#Comment_33553If you place the Javascript in look & feel -> Header, the script should work perfectly.
However, wondering is it only my laptop issue or what, after placing mattyb513 Javascript in to my survey, it take much more time in loading, I still learning Javascript and thinking is it because I hide the language drop down list using below CSS?
.LanguageSelectorContainer {display:none}

Leave a Reply