This question has been flagged
2 Replies
7991 Views

Hi !

I'm trying to translate my own module. Some sentences are in the code, and aren't included in the output file while I do Settings > Import/Export > Export Translation. So I'm trying to include these sentences manually.

So far, I've just achieved including them in the database. But something is wrong, because they are not used by openERP. I mean, the sentences are not translated when I use my module, but I can see the sentences in the ir_translation table.

A sample of my i18n/fr.po file:

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

I think the second line can do the trick, but I don't know the syntax. Someone know how to do that ?

Thanks !

Avatar
Discard
Best Answer

Hi,

Here is an example from contact module[English -> Spanish] :

#. module: contacts
#: model:ir.ui.menu,name:contacts.res_partner_menu_config
msgid "Configuration"
msgstr "Configuración"

For more refer https://www.cybrosys.com/blog/how-to-add-translation-to-the-custom-module-in-odoo-15

Regards

Avatar
Discard
Best Answer

Getting the translations to update and show up seems to be a bit hit or miss, but this is how I have got everything to show up, except for new states:

  1. Save all your module's xml and py files, and remember to use from tools.translate import _ in python
  2. If you haven't already, enable the language you want to translate to from Settings -> Load a translation
  3. Restart the server with the --update=my_module_name flag
  4. Go to Settings->Export translation. Choose the language you want to translate to, select PO as the file format, and pick the module you want to translate.
  5. Save the result to my_module_name/i18n/fi.po (replace fi with your proper language code)
  6. Edit the .po file with a text editor and add the translations there, don't touch anything else than just the msgstr rows. Save the file.
  7. After you have translated everything, restart the server with --update=all flag. Sometimes doing this twice has been required.
  8. Enable the new language for your user at Settings -> Users -> (username) -> Language
  9. Switch to that user and press Ctrl+R to refresh the UI

Hopefully this works for you as well.

Avatar
Discard
Author

Hi ! thanks for your answer. 1. In fact, I use from openerp.tools.translate import _ 2. I'm setting my language at the database creation, so I think I don't need it. But perhaps I'm wrong. 3. Again, I do not use this method. Instead, I use sudo service openerp-server restart , then in the interface I just update my module with the button. 4.5. I do exactly the same. 6. Here ! The problem is here ! When I do that, all the sentences are not in the file.