Hello!
I have a survey that is in both English and Spanish, and I have set up a calendar in one question using flatpickr. I'm trying to change the code so that participants who complete the survey in English see months in English and Spanish participants see months in Spanish. This is my code so far:
Qualtrics.SurveyEngine.addOnload(function () {
var input = jQuery("#"+this.questionId+" .InputText");
var languages = {
"ES-ES": {
months:["enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"],
},
"EN" : {
months:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
}
};
input.flatpickr({
l10ns: languages['${e://Field/Q_Language}'],
dateFormat: "m/d/Y",
minDate: "12/01/2019",
maxDate: "today"
});
});
I tried to adapt some code for pikaday (https://www.qualtrics.com/community/discussion/6074/date-picker-translations), but obviously I'm doing it incorrectly. Does anyone have any ideas? Thanks so much!
Shivani
Solved
Change language using flatpickr
Best answer by TomG
This should work:
Qualtrics.SurveyEngine.addOnload(function () {
jQuery("#"+this.questionId+" .InputText").flatpickr({
locale: "${e://Field/Q_Language}".substr(0,2).toLowerCase(),
dateFormat: "m/d/Y",
minDate: "12/01/2019",
maxDate: "today"
});
});
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
