Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
7873 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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)"

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

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

Tác giả

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

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
2666
0
thg 5 21
4151
Website translation Đã xử lý
2
thg 3 15
5367
1
thg 1 25
13299
4
thg 5 23
8964