Odoo Help


How to create localized string in python

Justin Lessard
on 9/16/15, 12:53 PM 1,475 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?


Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

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.


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