This question has been flagged
2 Replies
8381 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 ?

Avatar
Discard
Best Answer

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
Avatar
Discard
Author

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

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?

Author

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?

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

Author

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

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.

Author

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

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?

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 ?

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

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.

Thank you Yannik, I take a look at your link

Best Answer

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.
Regards

Avatar
Discard