Odoo Help

1

How to export translation strings from mako templates

By
Robin Hafen
on 8/31/14, 4:16 PM 1,462 views

I made several reports using webkit in Odoo 7 and packaged them in a module. In these reports I inserted literal strings like this:

${_("Some string")}

I now would like to translate all these strings to different languages. If I export the translation for the module using the translation export wizard under "Settings" I just get an empty file (PO or CSV). Am I missing something?

1
Robin Hafen
On 9/1/14, 10:42 AM

I managed to do it, although I'd be glad if somebody may shed some light on why you have to do it this way and what other possibilities there may be. Anyway, if anybody faces the same problem, here is my solution:

Assuming that your mako templates are stored in your module directory 'my_module' in the subfolder 'reports':

You can create the PO file which holds the translation strings (assuming you are on Linux and that your target language is German) using xgettext.

$ xgettext my_module/reports/*.mako -o de.po -L Python

This will create the file de.po, which you now have to edit further.

  1. 1. At the top of each entry generated by xgettext, add a line indicating the name of your module as shown below.
  2. Edit the msgstr to match your target language.
  3. Prepend 'addons/' to 'my_module' as shown below even if your module won't be placed in an 'addons' directory.

#. module: my_module
#: report:addons/my_module/reports/delivery_slip.mako:26
#: report:addons/my_module/reports/purchase_order.mako:41
#: report:addons/my_module/reports/sale_order.mako:41
msgid "Shipping address"
msgstr "Versandadresse"

Include all the files in "my_module/i18n" and they should be imported automatically on installation/upgrade of your module. You can also edit the translations under the 'Translated Terms' section in the web interface.

 

0
Katherine Zaoral
On 12/4/14, 11:37 AM

HI Robin Hafen +1 for you. I have no enoght karma to comment your answer directly. Your approach result for me. I create a new en.po file with the mako terms and then I cut and copy the terms I need to the .pot in my module.
Also, I have to say that I use an extra parameter for the xgettext command "--from-code=UTF-8".
I hope this could be helpfull.
Regards

 

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 8/31/14, 4:16 PM
Seen: 1462 times
Last updated: 3/16/15, 8:10 AM