OCA / odoo-pre-commit-hooks

Linters of Odoo addons that complement pylint-odoo
GNU Affero General Public License v3.0
9 stars 11 forks source link

Don't use empty string for redefined translatable terms #100

Open voronind opened 1 month ago

voronind commented 1 month ago

Odoo 15. In my module I redefine crm module translation. I want to translate CRM to CRM.

po-pretty-format replace it to empty string and my translation ignores. Can we check module name?

#. module: crm
#: model:ir.ui.menu,name:crm.crm_menu_root
#: model_terms:ir.ui.view,arch_db:crm.digest_digest_view_form
#: model_terms:ir.ui.view,arch_db:crm.res_config_settings_view_form
msgid "CRM"
msgstr "CRM"  --> ""
moylop260 commented 1 month ago

Sorry, I didn't get you

Original term is "CRM"

You want to translate it to "CRM"

(It means, you want to use the same original term than translated one)

Right?

The part I didn't get you is

my translation ignores.

I expect a empty string use original term like you translation

But what is the value used then?

voronind commented 1 month ago

Module crm has shitty translation of CRM term in my language. I want keep original term (CRM). I created module crm_translation and add in i18n directory:

#. module: crm
#: something
msgid "CRM"
msgstr "CRM"

po-pretty-format hook replace msgstr to "" (empty string) and Odoo uses shitty translation from crm module.

moylop260 commented 1 month ago

@voronind

You have a good point

You need to redefine to original English term in order to overwrite the translated term

This static checker doesn't have context about this case since that it doesn't know the original module/file terms

So, you have diferent workaorund here since that it can not be fixed

1) Fix the wrong translated term from weblate 2) Disable "autofix" option for this checker in your configuration files 3) Discard this special file for this checker in your configuration files

luisg123v commented 1 month ago

Hi @moylop260,

Thinking it better, maybe removing an existing translation is a valid case, as long as it's under the directory i18n_extra.

The reason for clearing translated terms is to generate a file as similar as possible to the one exported by Odoo, and to mimic the behavior (if the term is from our module, there's no need to fill the translation, because result will be the same). But since when dealing with manual translations (i18n_extra) terms will be from other modules, leaving the term empty and fill it with the same string as the original term will have different behaviors. Actually, it wouldn't make much of a sense to include a term in the i18n_extra directory and leave translation empty, because it will be ignored.

What do you think?

Regards,

moylop260 commented 1 month ago

@luisg123v

Who should take care about excluding files, the hooks itself or the pre-commit configuration file?

luisg123v commented 1 month ago

@moylop260 I think the file shouldn't be excluded, it just should change its behavior depending on if it's under i18n or i18n_extra:

moylop260 commented 1 month ago

@voronind

In this case, are you using a i18n_extra/*.po file?

voronind commented 1 month ago

I am using i18n/. I dont know difference between them

пт, 26 июл. 2024 г., 07:36 moylop260 @.***>:

@voronind https://github.com/voronind

In this case, are you using a i18n_extra/*.po file?

— Reply to this email directly, view it on GitHub https://github.com/OCA/odoo-pre-commit-hooks/issues/100#issuecomment-2251898742, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMBIUW22YCMI2CXWN55TN3ZOG75XAVCNFSM6AAAAABLFJ5OVGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJRHA4TQNZUGI . You are receiving this because you were mentioned.Message ID: @.***>

luisg123v commented 1 month ago

@voronind i18n is for translations that belong to your own module, while i18n_extra is intended to modify translations from other modules.