This question has been flagged
6661 Views

Hi !

What's the right way ?

from tools.translate import _

or

from openerp.tools.translate import _

?

Here's three samples of python code. Am I using '_' correctly ?

return _("This is an empty purchase order. Please add some lines.")

raise osv.except_osv(_('Shipping rule error'), message)

condition_string = _(' if %s %s %s %s') % (field_string, sign, str(value), symbol_string)

No matter what I do, I can't translate the hard coded strings. They don't even appear in my po file !

UPDATE :

Okay, now I try to add manually the sentences to both my french po file and my pot file. After openerp restart, I can see the sentences in the ir.translation table (via pgadmin3), but they are not used in the web client. I'm still with the english sentences. Here's a sample of what I've add :

#. module: shipping
#: view:shipping_rule:0
msgid "Shipping rule error"
msgstr "Erreur de règle de frais de port"

I think my mistake is in the second line, but I don't know what to put in place of that. Do someone knows how to fill this line properly ?

Thanks !

Avatar
Discard

Hi Yann. Install the module in some database and export the translation of this module in po format.

Author

I know that, I've done that, but, in the po file, the hard coded sentences I want to translate with "_" are missing... Why ? That is my question.

The truth is that I've to add all my hardcoded sentences to my po file. System is not doing that, Well in my case, it could be great if this could work.

Author

:O Ok, thanks Grover, I'll try this...

Author

Ok, I've had some lines to my po file. Checked ir.translation with pgAdmin, all fine. But the sentences are still not translated in the web client....

Did you get any solution?

Author

Alas no :/

Check for duplicate translations in the table ir.translation. I hade the same problem, and it turned out that there were 2 translation for the same resource, and one of them was actually a non-translation (the translated term was equal to the original one) and that was the one used by the client. I deleted that record and it worked.