Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
2405 Vizualizări

Hello !

I would like to translate some sentences inside my python code (for example, sentences displayed when a UserError occurs).

I use the get-text like method : _() to be able to translate those terms.


When I export a .po file for a specific language (or a new one), I find the sentences I want to translate but when I add a translation and import it, those translations do not seem to be taken into account by odoo.


So I checked inside the odoo code and it seems that "code" lines are not taken into account by odoo when odoo process the imported po file :

https://github.com/odoo/odoo/blob/cdd57b72241052dbb57e016ca9dcb036e250887b/odoo/tools/translate.py#L1269


So my question is the following : How do you manage to translate those sentences inside your python code ?


Thank you in advance.

 

Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

Commonly we are using “underscore” to indicate that the static string used in the code needs to be translated. Also you need to import this at the beginning . Like,

from odoo import _

Refer following image


Regards

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
4
iul. 24
6875
2
iul. 24
4245
4
iun. 24
25569
3
apr. 24
2437
1
feb. 24
4314