oTree Forum >

Multiple languages in same session

#1 by Scott

Hi there,

I've looked at the multi_language code form the otree-snippets, and the "Multiple languages within a session" question in this forum, but neither really solve my issue.

I have and otree app that requires groups of 4 people which speak 2 different languages. We need to run a session where they can play together, in their native tongue - 2 in Hebrew, 2 in Arabic.

Is there a way to do this using .po files? There are 7 apps within the project of varying complexities, so littering the code with if, elif, else would get really messy. (The app was developed in English).

Thanks for you help
Scott

#2 by Scott

It turns out it quite easy to do this on otree 3 as it uses Django

I added a front page with a dropdown list of countries, and the choices map this onto the ISO country code (en, he, ar in this case).

I write this into the participant.vars for each player, and then add an inner 'language' statement to each block in the HTML templates and it works, each player in the session can use their preferred language!

{% block content %}
{% language participant.vars.language %}
...
{% endlanguage %}
{% endblock %}

Chris, is this something that can be added to otree5?

Write a reply

Set forum username