IdSurvey 6: Create a multi-language questionnaire

Compatibility:IdSurvey 6IdSurvey 7
X

With IdSurvey you can create a multi-language questionnaire by using a simple script. Within the same survey the interviewer or respondent can decide which language to use to display the questionnaire.

To create a multi-language questionnaire in IdSurvey 6 you have to use IdCode.

Instructions

To create a multi-language questionnaire go to “Settings” section of the Survey Menu, click on “Advanced” Settings tab on the left of the page. Click on “Edit Script” and copy in the box the Javascript below to activate multi-language.

<style>
 span[lang]{display: none;}
 #LStyle, {display: none;}
</style>
<div id="LStyle"></div>
<script>
 var spanlang="{Field1}";
 var addedL = false;
 
$(function(){
$(document).on("core.pageRendered", function(e, opts){
 
 if(spanlang != "" && !addedL){
 $("#LStyle").html("<style>span[lang='" + spanlang + "']{display:inline;}</style>");
 addedL = true;
 }
 
 });
}); 
</script>

multilang_global

multilang_javaglobal

PLEASE NOTE: the system uses “Field1” to store preferred language code. This field shouldn’t be used for other information on “Contacts Management” or for “Update Quota” function.

Then you have to go to “Questions” section of the Survey Menu and insert at the beginning of your questionnaire a single select question to select the preferred language (for example, English or Italian).
In the gearwheel button of the page you’ve just created you enable “Client Script” and you copy in the box this javascript you find below.

  <script>
 $(":radio").on("change", function(){
 if($(this).is(":checked"))
 {
 addedL = false; 
 var sp = $(this).closest("li").find(".spanLang"); 
 spanlang = sp.attr("data-lang").toUpperCase();
 }
 });
 </script>

 

multilang_javaquestion

Answer options of this question will be all languages you want to program the questionnaire with (in the example English or Italian).

Once you created the questions with languages options, you open IdCode and insert in the answer options the span class with language tag before and after the text of the answer (in blue below):

IdSurvey 6.0 or later:

P1.Q1
 Select language:
 
 1 <span class="spanLang" data-lang="EN">English</span> 
 2 <span class="spanLang" data-lang="IT">Italian</span> 

In the span you will be able to modify the language codification between inverted commas with the codification of language you’ll be using (IT, EN, ES, FR, DE, etc.). The codification (span class) will have to be the same anywhere else in the questionnaire.

For each answer option inserted you have to click the gearwheel button, enable the “Update Quota“, select Field1 (where the system will save the codification of language selected) and in the box below write the language codification. In your example is “Field1” EN for English answer or IT for the ITALIAN answer.

multilang_setcode

This same setting can also be done in IdCode.

multilang_setlang

Then for all questions you will have to insert texts of questions and answers both in English and Italian (or any other language you use), use span tags in the IdCode for each language as you did for first question. For example:

  P2.Q2
<span class="spanLang" data-lang="EN"> Which country would you like to visit? </span> 
<span class="spanLang" data-lang="IT"> Quale paese ti piacerebbe visitare?</span>


  1 <span lang="EN">United Kingdom</span>  <span class="spanLang" data-lang="IT">Regno Unito</span>

  2 <span lang="EN">Italy</span>  <span class="spanLang" data-lang="IT">Italia</span>

  3 <span lang="EN">Spain</span>  <span class="spanLang" data-lang="IT">Spagna</span>

  4 <span lang="EN">France</span>  <span class="spanLang" data-lang="IT">Francia</span> 

  5 <span lang="EN">Greece</span>  <span class="spanLang" data-lang="IT">Grecia</span>

  99 <span lang="EN">None</span>  <span class="spanLang" data-lang="ES">Nessuno</span>

multilang_followingquestions

In the GUI you will display texts of questions and answers in all languages:

multilang_followingquestionsgui

In final interface, the respondent or interviewer will display only the language he/she selected in first question.

If the interviewer/respondent needs to change language while the questionnaire is ongoing, he can go back to question one and change language selected.

Leave A Comment?