Odoo Help


Report translation with Mako

on 2/22/13, 9:58 AM 5,006 views

How do you translate phrases from within a mako report? I have changed the target language with <% setLang(o.partner_id.lang) %> and tried using ${_()}, however only the original term is rendered, despite the fact that translations exist for the same string, for different fields, and no "untranslated" record is saved in the translations section...

Any idea ?


Yannick Vaucher - Camptocamp

--Yannick Vaucher - Camptocamp--

| 5 7 9
Lausanne, Switzerland
--Yannick Vaucher - Camptocamp--
Yannick Vaucher - Camptocamp
On 2/22/13, 10:11 AM

You might need to set the language first if you didn't.

For exemple in invoice_webkit module in account_invoice.mako we take the invoice partner language.

%for inv in objects:
<% setLang(inv.partner_id.lang) %>

And then you use the ${_("my text")} format.

For your translations, I'm not sure OpenERP add automatically those in the database when synchronizing it.

If you make them in a .po file, it should look like this:

#. module: invoice_webkit
#: report:addons/invoice_webkit/report/account_invoice.mako:129
msgid "PRO-FORMA"
msgstr "PRO-FORMA"

Otherwise, you might have to add them by hand in the translations.

  • Source: PRO-FORMA
  • Translation Value: PRO-FORMA
  • Translated field: addons/invoice_webkit/report/account_invoice.mako
  • Language: French
  • Type: Report / Template

Hi, thanks for your reply. I should have said that I have already done this (I have updated my answer with this information)

on 2/22/13, 10:12 AM

As your translations might not having been added by the synchronise translation wizard, as it certainly ignores ".mako" files I added some more info. Have you that kind of translation in your database or only for fields?

Camptocamp SA
on 2/22/13, 10:24 AM

Thanks again for the information. Unfortunately I am doing this on the SaaS, therefore there is no mako file path - I am saving the mako code directly in the report_webkit_mako text field. In this case, what do I put in the "Translated Field" field? Also, I assume Language is the target language, as it is assumed everything has its source as english?

on 2/22/13, 10:25 AM

Yes the Language is the target language, what is in source is always in english.

Camptocamp SA
on 2/22/13, 10:26 AM

Thanks, and what goes in the "Translated Field" field when using the report_webkit_mako field instead of a file path?

on 2/22/13, 10:30 AM

On SaaS, okay, try to add the translation by hand but then instead of path in Translated Field try to set the id of the report.

Camptocamp SA
on 2/22/13, 10:32 AM

So to sum up, the problem was fixed by manually creating a Translation Term with Type = 'Report/Template', Field Name = 'model_name', Resource_ID = ''. Thanks very much for your help

on 2/22/13, 11:47 AM

Hi Yannick, I noticed that in some cases the translated terms of a webkit report and included in the file "po" in the application i18n are not reported in the press, but are either replaced with a generic term related to the object or are not translated. If I go to check out the lines of the translation, however, are present, what would it be?

Agile Business Group sagl, Franco Tampieri
on 3/20/13, 5:41 AM

Hello User 12396 :)

I'm not sure to understand your question. Could you give me an exemple of an existing line that has a translation line and not being present in po file ?

Camptocamp SA
on 3/20/13, 9:10 AM

I'm sorry, maybe I did not explain properly, but I often report on webkit that replace the standard reports such as the sale_order or account_invoice, where po when I export the file and translate terms such as 'VAT' then reloading the translation and do the update of the module and the translation I is again the old translation of the label, in order to get my maybe I should change the label 'VAT' in 'VAT' and after repeating the whole process this work. What could it be? But if you know a better way to make tranlation files please explain to me. Best Regards Franco

Agile Business Group sagl, Franco Tampieri
on 3/21/13, 6:24 AM

This seems to be a different issue than the one in this question. It can be a bug that you should report on launchpad or you could also open a new question there you will have enough place to explain step by step what the problem is. Here is a question about how to generate po file it might help.

Camptocamp SA
on 4/2/13, 10:17 AM

Thank you Yannik, I take a look at your link

Agile Business Group sagl, Franco Tampieri
on 4/3/13, 10:31 AM
Katherine Zaoral
On 12/4/14, 11:46 AM

HI Max , Indeed the approach of configuration is the one given in the Yannick Vaucher answer the recall now is how to generate the .po with the terms in the mako file.

Making this by hand is too tedious. To generate the .po file yo can use xgettext command like the example given in https://www.odoo.com/forum/help-1/question/how-to-export-translation-strings-from-mako-templates-61575.

After generate the po you can merge this terms with the .pot of your module to complete them.

I hope It helps.

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.


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)


Asked: 2/22/13, 9:58 AM
Seen: 5006 times
Last updated: 3/16/15, 8:10 AM