Odoo Help

0

How to create localized string in python

By
Justin Lessard
on 9/16/15, 12:53 PM 1,087 views

I already know I can localize python string using the following code:

localized_string = _('Resource key')

But when I go to Settings => Translations => Import/Export => Export translation , the generated file doesn't include any of the string localized using the aforementioned way.


Why is that, and how can I fix this?

1
Axel Mendoza
On 9/16/15, 1:27 PM

Those strings need to be added to the .po file using python-format like:

#. module: stock
#: code:addons/stock/stock.py:1662
#, python-format
msgid " (%s reserved)"
msgstr " (%s reservado)"

Thanks for your help. But my question was why aren't those line automatically generated when I export the module translation file. I tested it with Odoo defaults module and it works flawlessly, but theses lines aren't generated for my custom module.

Justin Lessard
on 9/16/15, 1:38 PM

When Odoo export your translation it export what it reside in the db and that kind of terms wouldn't be on the database if you don't define like the example before in a .po

Axel Mendoza
on 9/16/15, 1:46 PM

Then how come Odoo can generate resources for the text in the XML views?

Justin Lessard
on 9/16/15, 1:55 PM

viewing at the code of export translation there are functions to extract terms to translate from .py files

Axel Mendoza
on 9/16/15, 2:10 PM

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: 9/16/15, 12:53 PM
Seen: 1087 times
Last updated: 9/16/15, 1:27 PM