Whenever a user switches the language during a survey, (s)he is presented the new language after that. So far, so good.

But…. in the results table of LimeSurvey only the startlanguage is stored, not the language that you change to. We ran into this when someone in the customer organisation sent the link with the dutch startlanguage in it to respondents in the UK. These people happily started filling in the survey, after changing this to English.

But they did not know that the resulting report would be based on… yes, the startlanguage.

To overcome this we (we were helped through IRC by Deusdeorum, one of the dedicated users/developers) inserted a last short free text question called qlang with the following code:

<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:complete',function() {
$('#question{QID} input').val($('html').attr('lang'));
$('#question{QID}').hide(); });

What does this script do?

This script writes into a question the value of the language attribute, which is the current languge of the survey. After that it hides the question, so the respondent is not bothered with it.

This results in having the used language on the last page to the results table. When a script produces a report, you can better use the variable qlang than the startlanguage when you need the respondent’s language.

Tested in:

Limesurvey 2.6.7 (also known as 2.06+ LTS) and 3.x

tip: Javascript must be switched in in your LimeSurvey installation. To do that, you have to disable the Limesurvey XSS filter at:

Global settings -> Security -> “Filter HTML for XSS” = “No”