This question has been flagged
7 Replies
13519 Views

Hello ,

I have desigen custome report in odoo version 8 .

I know the translation is supported , but i wonder the way to translate the report based on user language ?

How can i implement the translate ?

Any idea will be helpful

Avatar
Discard
Best Answer

Hi Sameer

So if I understand correctly you want to make translations and change the report language as which language is set?
Every default report has two QWeb views. One with the actual report (named report_xxxx_document) and one record with the translation logic (report_xxxx)
In this second record, the report_xxx is where the languages will be fetched:

<?xml version="1.0"?>
   <t t-name="account.report_invoice">
       <t t-call="report.html_container">
          <t t-foreach="doc_ids" t-as="doc_id">
          <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'account.report_invoice_document')"/> </t>         </t>
</t>

As you can see this second record checks the language from the user with partner_id.lang and then loads the correct translation.
So, how do you get the correct languages?
You'll need to create a new folder named i18n and place a .po file in this for every language you want to translate.
The file should have the ISO language codes. For example for the Dutch language this would be nl.po.
In this file you should add the modulename, location of the value you want to translate, the source and the translation. For example:

#. module: sale
#: view:sale.order.line:sale.view_order_line_tree
msgid "Qty"
msgstr "Hvhd"

Simply do this for everything you want to translate, for every language, and then update your module.

Note: You can see examples in any module under the folder i18n. You have to do the same for your module but with other values and module names.

Best of luck

Avatar
Discard
Author

I have add the translate template , and add the translation file ar_SY.po in i18n folder . I add the translation as : #. module: mymodulename #: view:website:mymodulename.myfilename msgid "Arabic" msgstr "عربي" but not translate ? where is the wrong code ?

Have you updated your whole module? I assume that you've replaced mymodulename with your name and that you added it under i18n. Is the language for ar_SY.po also installed on the system and set for the customer / person where you want to have the translation shown?

Author

Yes [Updated] , I do all thing you have mentioned it in your answer , but with no changes in result . report not translated yet

Author

https://www.dropbox.com/s/fb71bu9ez2kc1wm/test_module.zip?dl=0 this test module for everything you mentioned above .... Not Work ..

Best Answer

Just see for the reference in sale module in the ODOO 8.0 

translate the report of  sale order  for  your selected langaage.

 

I hope this should helpful for you .. :)

Avatar
Discard
Best Answer

Is there a way to translate the hr.expense report to the language of the customer mentionned in teh analytic account? I've tried to achieve this for a while on odoo 9 community, but it didnt work out yet

Avatar
Discard