Need help with translation system

I’m developing a payment plugin and I can’t get the translation to work in the templates.

In the render_payment_form returns:

return render_plugin_template('event_payment_form.html', **data)

The template is now very short:

{%- trans -%}RATest{%- endtrans -%}

Like with other translations, I put into translations/messages.pot

#: [...]/templates/event_payment_form.html:1
msgid "RATest"
msgstr ""

And the translations into the corresponding folders, as example for German translations/de_DE/LC_MESSAGES/messages.po:

#: [...]/templates/event_payment_form.html:1
msgid "RATest"
msgstr "RATest de"

But the output is always “RAtest”. What am I missing?

Did you compile the translations?

pybabel compile -f -d ./indico_yourplugginname/translations/ -l de_DE

I’ll try. But the other translations worked without compiling. I tested with a dev version of 3.2.1 locally previously. Now running a “real” server with latest Indico.

That’s strange. The plaintext .po file is usually never used, only the compiled .mo file is…

Indeed. I also assumed the .mo would be needed or Indico would generate them itself. But it worked with only .po
Anyway, thanks! With compiled .po it works as intended :slight_smile:

Btw. how do the other handle that problem? I don’t see any .mo in the sources of other plugins.

Most people probably do not care about plugin i18n and might not even bother with .po files

Our own plugins do have translations though:

[adrian@eluvian:~/dev/indico/py3/plugins/public:master *]> ll **/*.po | wc -l

The corresponding .mo files are generated output and thus do not belong in Git repos. Generally you’d compile them just before building the Python wheel for the plugin (either to release on PyPI or to install on your instance).