oTree5 and localization

77 views
Skip to first unread message

Matteo Ploner

unread,
May 11, 2021, 6:23:48 AM5/11/21
to oTree help & discussion
Dear oTree Community,

I followed instructions https://otree.readthedocs.io/en/latest/misc/internationalization.html, but I have problems with oTree5 and localization and maybe you can kindly help me.

Specifically:

1) When I give the command "pybabel extract . -F babel.ini -o messages.pot -k trans"
the text identified by {{ trans 'my text here' }} does not show up in the messages.pot file. Surprisingly, the text identified by {% trans 'my text here' %} instead shows up in messages.pot (which I can then edit).

2) When I give the command "pybabel compile -i messages.pot -d _locale -l it -f" the file messages.mo gets created in the project root folder _locale/it/LC_MESSAGES/and it is not empty. However, even if I set LANGUAGE_CODE="it" in settings.py and restart the server,  the translation does not show.

In the process, I do not get any error messages.

Several of my "old" apps are multilanguage and I am struggling to convert them into oTree5. Any help is very much appreciated.

Thank you,
Matteo

Chris @ oTree

unread,
May 11, 2021, 6:52:04 AM5/11/21
to oTree help & discussion
OK i see the issue, I will fix ASAP, thanks for reporting.

Chris @ oTree

unread,
May 11, 2021, 7:09:59 AM5/11/21
to oTree help & discussion
Hi, I fixed it; could you update and try again?

Chris @ oTree

unread,
May 11, 2021, 7:15:18 AM5/11/21
to oTree help & discussion
By the way, you should now use {{ trans }} and not {% trans %}; I fixed that issue.

Matteo Ploner

unread,
May 11, 2021, 7:33:30 AM5/11/21
to oTree help & discussion
Hi Chris,
I updated and it works!
Thank you very much,
Matteo

Reply all
Reply to author
Forward
0 new messages