odooodoo-8odoo-9

Override translation from original module


How can I override translation of default_code field?

in inherited Product Template and Product Product, I added fields

default_code = fields.Char(
        string='Articul',

        related='product_variant_ids.default_code')

and

 default_code = fields.Char(
        'Articul', select=True)

string changes in the English version but if I change to my language then I get an original translation.

So i tried to copy a part from original modules translation and add it to my po file like this.

#. module: product
#: model:ir.model.fields,field_description:product.field_product_product_default_code
#: model:ir.model.fields,field_description:product.field_product_template_default_code
msgid "Articul"
msgstr "Articulas"

it works but when I want to update my file with Poedit I getting an error

2018 m. liepos 30 d. 15:43:37: /tmp/poedituUNIro/1input.po:1023: duplicate message definition...
2018 m. liepos 30 d. 15:43:37: /tmp/poedituUNIro/1input.po:169: ...this is the location of the first definition
2018 m. liepos 30 d. 15:43:37: msgmerge: found 1 fatal error
2018 m. liepos 30 d. 15:43:37: Entries in the catalog are probably incorrect.
2018 m. liepos 30 d. 15:43:37: Updating the catalog failed. Click on 'Details >>' for details.

Solution

  • No need to redeclare the field string!

    1. Export the translation file from the add-ons you want to override.
    2. Translate it using POEeit or similar.
    3. Drop the translation file inside a i18n_extra folder in the addon. E.g.: addon/i18n_extra/fr.pot
    4. Update the addon.

    With that system, a submodule is able to override translations from parent modules.