How can I use JavaScript to translate "Character remaining:" from the alternative language to my custom language? | XM Community
Skip to main content

Hello, I'm conducting a survey in a non-regular language that isn't available in the default list provided by Qualtrics. I've created a custom language option and selected "Thai" as an alternative language. As a result, all the general messages within the survey are currently displayed in Thai. For instance, below the text entry box, the "Character remaining:" message is in Thai.

I'm wondering how I can use JavaScript to change the Thai script to my language script while keeping the English version unchanged.

Thanks!

You can change the text of specific elements based on language code. To change how “Characters remaining: ” displays for a custom language, you can add the below to the OnReady of the Text Entry question’s JavaScript, updating the “ZZ” language code with whatever you defined for your custom language.

var charRemaining = document.getElementById(this.questionId+"-RemainingChars");
if("${e://Field/Q_Language}" == "ZZ") {
charRemaining.firstChild.textContent = "ZZCharacters remaining: ";
}

 


You can change the text of specific elements based on language code. To change how “Characters remaining: ” displays for a custom language, you can add the below to the OnReady of the Text Entry question’s JavaScript, updating the “ZZ” language code with whatever you defined for your custom language.

var charRemaining = document.getElementById(this.questionId+"-RemainingChars");
if("${e://Field/Q_Language}" == "ZZ") {
charRemaining.firstChild.textContent = "ZZCharacters remaining: ";
}

 


Hi Tom, thank you very much for your codes and help! I tried your codes, but they're not working for me.

I also tested the English version - updating ZZ with "EN," but nothing changes as well.

Did I miss anything?


Hmm below is my setup:

  • Layout: Flat
  • Question Type: Text Entry
  • Text Type: Multiple lines or Essay
  • Validation-Character Range: Min = 1, Max = 500
  • Text Entry Question JavaScript:
Qualtrics.SurveyEngine.addOnReady(function()
{
    /*Place your JavaScript here to run when the page is fully displayed*/

var charRemaining = document.getElementById(this.questionId+"-RemainingChars");
if("${e://Field/Q_Language}" == "ZZ") {
    charRemaining.firstChild.textContent = "ZZCharacters remaining: ";
    }
        
});

Does this match what you have on your end? If yes and you still aren’t seeing any updated text, would it be possible to share a preview link of your survey?


Hmm below is my setup:

  • Layout: Flat
  • Question Type: Text Entry
  • Text Type: Multiple lines or Essay
  • Validation-Character Range: Min = 1, Max = 500
  • Text Entry Question JavaScript:
Qualtrics.SurveyEngine.addOnReady(function()
{
    /*Place your JavaScript here to run when the page is fully displayed*/

var charRemaining = document.getElementById(this.questionId+"-RemainingChars");
if("${e://Field/Q_Language}" == "ZZ") {
    charRemaining.firstChild.textContent = "ZZCharacters remaining: ";
    }
        
});

Does this match what you have on your end? If yes and you still aren’t seeing any updated text, would it be possible to share a preview link of your survey?


I've identified where the issue lies: when I preview that particular question only in the edit mode, nothing changes. However, if I click the link to start the survey from the beginning, the codes actually work and the updated text show up! Thank you so much!


Leave a Reply