Determine the current language in a multi language form

Hello Everyone,

I have not seen an existing topic/posting for this query, so creating a new one…

Is there a way to know the language selected in a multi language form at run time? Is there a ‘metadata’ (like username) that can tell the language the user has selected for data entry (from the dropdown in the top right corner of a kobotoolbox form) in a multi language form?
This information can then be used, for instance, to set a language specific label for a question. Other uses too.

thanks

@aaj, this is still not possible through the system. But please be informed that we do have a features request already for the same:

Maybe you can VOTE for the same to make it a reality in the near future. Please also feel free to reach us back if you/your organization would like to sponsor this feature.

Thanks @Kal_Lam. I voted for feature request you shared by posting a reply on it. Hope that is the process for voting?
Hope the feature request I just voted for, provides the language selected as a metadata variable at ‘run time’, like ${language} for example?

thanks

Perhaps, as a workaround you could use a function giving a language-based result, e.g.
with a select_one variable, using jr:choice-name() function with comparison to the language-specific labels.

Hint: But be aware, that a form user can change the language anytime, even in the same form.
So, the language setting is only registered for the (last) data entry of a specific question/variable.

Here is an example (EN / AR), Language01.xlsx (15.0 KB)

This example also shows that at least in Enketo there is a problem (bug?) that the initial default_language setting is not correctly applied for the format-date() function, if this is not the browser configuration language. There is also a problem in Collect, if the device language is different to the ODK/form app.

2 Likes

Thanks @wroos! I’ll give this a try

1 Like

Could you explain, what you exactly want to do with the language information, please?

This is (easily) done by providing language specific labels (questions/variables, choices), And the same for hints, messages, media. See Adding Another Language to your XLSForm — KoboToolbox documentation.

1 Like

In some situations a label has to be set dynamically using a calculate/hidden question type:

This a very ‘crude’ example, but I hope you get the idea.

Such a label can currently only be set in one language - English in the above ‘example’. I have tried doing this using choices, and instance() function to pull the label but it does not work for multiple languages. Using jr:choice-name() function also did not work I think. Had done these tests a while ago.

jr:choice-name should work. Could you try, please.
Here an example: Language03.xlsx (14.6 KB)

1 Like

I too did a jr:choice-name() test just now. Yes, that works. However…you’ll notice that if the language is switched in-between form filling (which can happen), then the dynamic label will not change with the change in language, unless, at least in the case of example you have shared, the ‘select_one’ question value that it is dependent on, is changed (after the language switch). In the example I shared with you the dynamic label is dependent on the value of another question, but in one scenario that I have, the dynamic label is not dependent on another question (it is in a repeat group and depends on the row number, i.e. position(…) value). It will take some time to prepare an example/test case to share here, if you need one. Maybe I should have fully explained all this in the beginning. Apologies.

@wroos, I just saw that you had mentioned the ‘language switch’ limitation in an earlier (first) reply which I missed. Your first reply that I read was about the format-date() function based solution (which looks like you have deleted since then).