Chaban33
Chaban33

Reputation: 1382

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.

Upvotes: 2

Views: 3582

Answers (2)

omar ahmed
omar ahmed

Reputation: 663

To Override Standard Field Translation :

  1. override field (like:default_code) in custom module .
  2. GO --> Settings --> Translation --> Export Translation
  3. Export Wizard appear --> choose language to translate .. Export Type : module .. Apps To Export : (select your custom module) -- click 'Export'
  4. Download .po file and add in your custom module under "i18n" folder .
  5. In .po file find your field (like:default_code) and add it's translation .
  6. Finally : GO --> Settings --> Translation --> Import Translation and import your .po file .

Upvotes: 0

Yajo
Yajo

Reputation: 6418

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.

Upvotes: 5

Related Questions