Professional > Interview scripting > Writing interview scripts > Multiple-language scripts > Setting the interview language
 
Setting the interview language
The interview language controls not only the language in which questions, answers, and other texts are displayed but also the format in which decimal and date responses must be entered.
When a respondent starts an interview and the interviewing program has no information about the respondent’s language, it tries to find a suitable language for the interview. First, it checks whether the questionnaire file contain texts in the respondent’s browser language and, if so, uses that language. (If the respondent has a list of languages set in their browser, only the first language is checked.) If the questionnaire does not contain texts in the respondent’s browser language, the interviewing program uses the texts in the questionnaire’s base language (the default language set when the project was activated).
For example, suppose the questionnaire is defined in English (the base language) and Spanish. Participants whose browsers are set up to work in Spanish will automatically see Spanish texts and must enter decimal numbers with a comma as the decimal point. Everyone else will see English texts and must enter decimal numbers with a dot as the decimal point.
A better approach is to set the interview language in the script, either by asking a direct question or by extracting the respondent’s language from the sample record.
To set the language based on a direct question, define the list of available languages in the metadata section:
InterviewLanguage "In which language would you like to be interviewed?"
Notice that each language has its standard three-character code as its name as this is required for setting the language in the routing section.
Note In general you can set languages using their three-character code, as here, or their RFC 1766 format (en–gb or fr–fr, for instance). The interviewing program converts three-character references to RFC 1766 format.
In the routing section, set the chosen language as the interview language with:
IOM.Language = Qname.Categories[Qname].Name
where Qname is the name of the language question. For example:
InterviewLanguage.Ask()
' Set the interview language
IOM.Language = InterviewLanguage.Categories[InterviewLanguage].Name
' Force comma for decimal places and yyyy-mm-dd dates
IOM.Locale = 1045 ' Polish locale
If the respondent’s preferred language is defined in the sample record, you can import it from there. For example, if the preferred language is stored in the Language sample field, you would type:
IOM.Language = IOM.SampleRecord["Language"]
For more information, see Using sample data in interviews.
Note The interview scripting language accepts setting the interview language to any language that you like. However, the interviewing program requires the questionnaire (.mdd) file to contain that language even if there are no translations for it yet. If the script instructs the interviewing program to use a language that does not exist in the questionnaire file, the interviewing program writes a warning to the IVW*.tmp log file and then continues the interview using the default language that was set during activation. The warning says “Language 'xxx' is not available, using 'yyy' instead”.
See also
Multiple-language scripts