Calendar question: How to translate | XM Community
Skip to main content
In my first question I ask the user for their preferred language.

Depending on their answer the survey changes language

using the following script for the onload function of the following question that is in a separate block ==>jQuery("select").val("${e://Field/Q_Language}").prop("checked",true);



However, I want to add a question in between asking the date they visited us (using the calendar survey question from the library). I want the question text to differ per language, but when I translate the survey using tools and change the text in HTML it still shows the survey using the English question text.



How can I translate the calendar question from the library?



Thank you!
I think library have questions in English test only. You can add translation for this question yourself.
@bansalpeeyush29 : if I add the translation using the translate survey tool and then changing the text in HTML view from English (Please select the date) to Dutch (Gelieve de datum te selecteren), it doesn't translate it to the when published. Should I be adding something specific to the HTML text?

See attached the script from the question as example



I only changed the text in the first paragraph between the <strong></strong> from "Please select the date" to "Gelieve de datum te selecteren"



Thanks for helping me out!
@LauraHill_95,



It sounds like you added the calendar question immediately after the language question and before the question with the JS that changes the language. So, it sounds like you have to move the JS that changes the language to the calendar question.
@TomG Hi Tom, thanks for your answer. I changed the JS that changes the language to the calendar question, but it doesn't seem to make a difference. Should I also write the following JS that I used somewhere in the HTML view of the question text? Thanks in advance!



(Qualtrics.SurveyEngine.addOnload(function()

{

/*Place your JavaScript here to run when the page loads*/



jQuery("select").val("${e://Field/Q_Language}").prop("checked",true);

});



Qualtrics.SurveyEngine.addOnReady(function()

{

/*Place your JavaScript here to run when the page is fully displayed*/



});



Qualtrics.SurveyEngine.addOnUnload(function()

{

/*Place your JavaScript here to run when the page is unloaded*/



});
Actually, I was surprised your code to change language was working to begin with. I think you need to trigger the change event:

```

jQuery("select").val("${e://Field/Q_Language}").prop("checked",true).change();

```

Personally, I never put JS in the Question Text. I use "Add JavaScript..." If I load external JS libraries, I do in the survey header.



Also, I think the calendar from the Qualtrics library is really clunky. I use flatpickr instead. You can do localization by piping an appropriate value into the options. There are a number of Community posts about flatpickr.
@TomG Thanks!

Leave a Reply