Can I find out language setting? | XM Community
Skip to main content
I am trying to setup a Qualtrics survey that inserts custom text into a matrix question (written by javascript). The issue is that I have multiple languages. How do I use if statements to determine the language that the survey is being completed in? I am using the drop down at the top, so it can be changed any time.



The code will be something like so (IF STATEMENTS ARE WHAT I NEED HELP WITH):



Qualtrics.SurveyEngine.addOnload(function()

{

IF Language is set to English:



var newRow = $('<tr class="Choice"><th class="Choice"><span class="LabelWrapper"><label><strong>Travel to and from School</strong><BR>Note:

walking to and from school counts as 2 times.</B></label></span></th><td class="c2 BorderColor"></td><td class="Separator2 BorderColor c3">

</td></tr>');

newRow.insertBefore ($('#QID58 tr:nth(4)'));



var newRow2 = $('<tr class="Choice"><th class="Choice"><span class="LabelWrapper"><label><strong><BR>Other Types of Physical Activity.</B>

</label></span></th><td class="c2 BorderColor"></td><td class="Separator2 BorderColor c3"></td></tr>');

newRow2.insertBefore ($('#QID58 tr:nth(8)'));



ELSE IF Language is set to French:



var newRow = $('<tr class="Choice"><th class="Choice"><span class="LabelWrapper"><label><strong>aller et retour de l'école </strong><BR>Remarque:

marcher pour aller à l'école compte pour 2 fois. </B></label></span></th><td class="c2 BorderColor"></td><td class="Separator2 BorderColor c3">

</td></tr>');

newRow.insertBefore ($('#QID58 tr:nth(4)'));



var newRow2 = $('<tr class="Choice"><th class="Choice"><span class="LabelWrapper"><label><strong><BR>Autres types d'activité physique.</B>

</label></span></th><td class="c2 BorderColor"></td><td class="Separator2 BorderColor c3"></td></tr>');

newRow2.insertBefore ($('#QID58 tr:nth(8)'));

});





Thanks,



Andrew
Hi Andrew,



Using the following code will give you the language code chosen in Qualtrics Dropdown



`jQuery("#Q_lang").val();`



for eg. if French language is set in qualtrics it will return a string "FR" .



Regards,

Nihal Chirayath
@afclark82,



There is an easier solution than the way you are doing it. Create an MC question at the beginning of your survey for translations and hide it with display logic (add a condition that is always false, such as the non-existent embedded variable "hide" equal 1). The choices are the phrases you want to translate.



Then just pipe the choicetext from that hidden question into your JS, and it will be in the current language.

Leave a Reply