How to include a new language to Indico?

Hi there,

weve just finished translating Indico to pt_BR, 100%, using transifex.

How do we use these files in our Indico installation, is there any tutorial on how to include a new language to a running instance of indico?

Ive just copied all .po files to /translations/pt_BR, but the option to change langue to Portuguese does not appear on Indico menu?

Help!

Thanks in advance

1 Like

You need to use indico i18n compile-catalog to build the corresponding .mo file.

Example with the french one:

[adrian@claptrap:~/dev/indico/src:master]> ll indico/translations/fr_FR/LC_MESSAGES/
total 788
drwxr-xr-x 2 adrian users   4096 Dec 28 14:06 .
drwxr-xr-x 3 adrian users   4096 Dec 28 14:06 ..
-rw-r--r-- 1 adrian users  88475 Dec 28 14:06 messages-js.po
-rw-r--r-- 1 adrian users 708123 Dec 28 14:06 messages.po

[adrian@claptrap:~/dev/indico/src:master]> indico i18n compile-catalog
error: indico/translations/fr_FR/LC_MESSAGES/messages.po:2318: placeholders are incompatible
error: indico/translations/fr_FR/LC_MESSAGES/messages.po:2326: placeholders are incompatible
error: indico/translations/es_ES/LC_MESSAGES/messages.po:2640: placeholders are incompatible
error: indico/translations/es_ES/LC_MESSAGES/messages.po:2648: placeholders are incompatible
4 errors encountered.

[adrian@claptrap:~/dev/indico/src:master]> ll indico/translations/fr_FR/LC_MESSAGES/
total 1148
drwxr-xr-x 2 adrian users   4096 Jun  6 23:41 .
drwxr-xr-x 3 adrian users   4096 Dec 28 14:06 ..
-rw-r--r-- 1 adrian users  88475 Dec 28 14:06 messages-js.po
-rw-r--r-- 1 adrian users 365578 Jun  6 23:41 messages.mo
-rw-r--r-- 1 adrian users 708123 Dec 28 14:06 messages.po
2 Likes

Thanks ThiefMaster, but i have some questions.

Indico already have Fr language incorporated right? Now we are trying to build a new language, in this case, PT-BR. So i have some files that i downloaded from Transifex (.po files). Where do i put them.

Sorry, im not a linux user.

1 Like

You should put them in <INDICO_PATH>/indico/translations/pt_BR/LC_MESSAGES. However, we have already incorporated those translations in the latest commit in Indico. So, if you clone the repository you will see that the translations are already there :wink:

1 Like

Dear Kolodzie,

Sorry to bother, but how do i do that? I have absolute no knowledge ofn how to do it. I could only install Indico on my machine using this version: https://getindico.io/getting-started/ and following these procedures https://docs.getindico.io/en/latest/installation/production/
How do I “clone” a repository? Is there any tutorial about that?
Thanks in advance.

1 Like

If you are not a developer and/or intend to use it for production I would recommend you to wait until we release 2.2 (likely to happen beginning of July). The translations are for that version, so even if you did include them in 2.1.x (the current stable release), some strings would be missing/incorrect in case they were changed between 2.1 and 2.2.

Hi,

I tried to add zh_TW translations and compile it. However in my instances I can select my language as zh_TW but still can not see Traditional Chinese translations.

Is there anything to do besides compiling po file?

Thanks

Once you have the .mo file in the correct folder (see the folder structure for an existing translation like fr_FR) and restarted uwsgi (or the indico dev server if you are on a development server), the translations should work…

No, it didn’t. That’s why I wondered if .mo file took effects with errors… But I eliminated those erroneous messages it compiled successfully but still no Chinese interfaces.

Is there anything else I should check?

What does ls -Ral indico/translations/zh_TW show?

(.venv) indico@social:/opt/indico/.venv/lib/python2.7/site-packages$ ls -Ral indico/translations/zh_TW/
indico/translations/zh_TW/:
總計 12
drwxr-xr-x 3 indico www-data 4096 10月 27 17:44 .
drwxr-xr-x 7 indico www-data 4096 10月 27 19:03 ..
drwxr-xr-x 2 indico www-data 4096 10月 27 18:55 LC_MESSAGES

indico/translations/zh_TW/LC_MESSAGES:
總計 888
drwxr-xr-x 2 indico www-data   4096 10月 27 18:55 .
drwxr-xr-x 3 indico www-data   4096 10月 27 17:44 ..
-rw-r--r-- 1 indico www-data 133010 10月 27 18:54 messages-js.po
-rw-r--r-- 1 indico www-data  81909 10月 27 18:54 messages.mo
-rw-r--r-- 1 indico www-data 508167 10月 27 18:36 messages.po
-rw-r--r-- 1 indico www-data  22091 10月 27 18:55 messages-react.json
-rw-r--r-- 1 indico www-data 146841 10月 27 18:54 messages-react.po

That looks correct…

What do you get when executing this in indico shell?

from indico.util.i18n import get_all_locales
get_all_locales()
(.venv) indico@social:/opt/indico$ indico shell
Indico v2.2.4 is ready for your commands
In [1]: 
In [2]: from indico.util.i18n import get_all_locales

In [3]: get_all_locales()
Out[3]: 
{'en_GB': (u'English', u'United Kingdom'),
 'es_ES': (u'Espa\xf1ol', u'Espa\xf1a'),
 'fr_FR': (u'Fran\xe7ais', u'France'),
 'pt_BR': (u'Portugu\xeas', u'Brasil'),
 'zh_Hant_TW': (u'\u4e2d\u6587', u'\u53f0\u7063')}

Oops… something seems unexpected…

Do you have zh_Hant_TW somewhere in your .po file? This looks very much like the reason why it doesn’t work properly…

Update: I just checked the code and it looks like babel is doing this… can you check if it works when you name the folder zh_Hant_TW instead of zh_TW?

No. My messages.po is here: https://pastebin.com/scTvP6fF

Usually for locale we use zh_TW not zh_Hant_TW.

$ locale
LANG=zh_TW.UTF-8
LANGUAGE=zh_TW:zh
LC_CTYPE="zh_TW.UTF-8"
LC_NUMERIC="zh_TW.UTF-8"
LC_TIME="zh_TW.UTF-8"
LC_COLLATE="zh_TW.UTF-8"
LC_MONETARY="zh_TW.UTF-8"
LC_MESSAGES="zh_TW.UTF-8"
LC_PAPER="zh_TW.UTF-8"
LC_NAME="zh_TW.UTF-8"
LC_ADDRESS="zh_TW.UTF-8"
LC_TELEPHONE="zh_TW.UTF-8"
LC_MEASUREMENT="zh_TW.UTF-8"
LC_IDENTIFICATION="zh_TW.UTF-8"
LC_ALL=

zh_Hant_TW should be defined in the i18n scheme in Indico I suppose…

Yes, it works when I symlink zh_Hant_TW to zh_TW.

BTW, the Room booking system did not show Chinese even I use zh_Hant_TW. I have run compile-catalog-react and messages-react.json has been created. The Indico system showed Chinese (with zh_Hant_TW) but Room booking system did not.

What may be wrong here?

It might be related to the issue with the name of the locale. Check “View source” and search for a line similar to this (with the chinese locale of course):

<script type="text/javascript" src="/assets/i18n/en_GB-react.js"></script>

Then see if the URL it references actually works. My guess would be that this includes / doesn’t include the “Hant” part, and the file is served without / with it. If that’s the case we’ll have to fix this on our side next week…

<script type="text/javascript" src="/assets/i18n/zh_Hant_TW.js"></script>
<script type="text/javascript" src="/assets/i18n/zh_Hant_TW-react.js"></script>

In /assets/i18n/zh_Hant_TW.js:
window.TRANSLATIONS = {"indico":{"":{"domain":"indico","lang":"zh_Hant_TW"}}};

In /assets/i18n/zh_Hant_TW-react.js:
window.REACT_TRANSLATIONS = {"indico":{"":{"domain":"indico","lang":"zh_Hant_TW"}}};

Honestly I don’t have any idea what it means…

OK, so the problem is that those files are basically empty instead of containing the translations they should contain… This is pretty strange since according to your ls output earlier the files providing the data are clearly not (almost-)empty…

Try deleting /opt/indico/cache/assets_i18n_*.js in case indico cached old/empty data at some point…