From 1fb2d47b66567601ad5ce242e8afc7bf3ff6c5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20L=C3=B3pez=20-=20https=3A//www=2Evauxoo=2Eco?= =?UTF-8?q?m/?= Date: Wed, 4 Dec 2024 22:10:47 -0600 Subject: [PATCH] [FIX] po-pretty-format: Allow original=translated term for "i18n_extra" folder (#113) Autofix is clearing the translations where the original term is the same than translated one e.g. msgid "CRM" msgstr "CRM" --> "" However, there are valid cases to reset the translated value But it should be only for i18n_extra folder More info https://github.com/OCA/odoo-pre-commit-hooks/issues/100 --- .../checks_odoo_module_po.py | 8 +++++--- test_repo/test_module/i18n_extra/fr.po | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 test_repo/test_module/i18n_extra/fr.po diff --git a/src/oca_pre_commit_hooks/checks_odoo_module_po.py b/src/oca_pre_commit_hooks/checks_odoo_module_po.py index ec4091f6..3fcbaa0a 100644 --- a/src/oca_pre_commit_hooks/checks_odoo_module_po.py +++ b/src/oca_pre_commit_hooks/checks_odoo_module_po.py @@ -75,9 +75,11 @@ def __init__(self, po_filename, enable, disable, autofix): def _compute_pretty_contents(self): self.po_data.sort(key=lambda entry: entry.msgid) - for entry in self.po_data: - if entry.msgid == entry.msgstr: - entry.msgstr = "" + # Ignore i18n_extra https://github.com/OCA/odoo-pre-commit-hooks/issues/100 + if self.data_section != "i18n_extra": + for entry in self.po_data: + if entry.msgid == entry.msgstr: + entry.msgstr = "" self.pretty_contents = str(self.po_data) diff --git a/test_repo/test_module/i18n_extra/fr.po b/test_repo/test_module/i18n_extra/fr.po new file mode 100644 index 00000000..1793c282 --- /dev/null +++ b/test_repo/test_module/i18n_extra/fr.po @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 1985-04-14 17:12+0000\n" +"PO-Revision-Date: 1985-04-14 02:03+0000\n" +"Last-Translator: Moisés López \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: test_module +#: model:ir.model.fields,field_description:test_module.field_description +#, python-format +msgid "same msgid msgstr allowed for i18n_extra" +msgstr "same msgid msgstr allowed for i18n_extra"