Skip to content

Commit

Permalink
[REF] po-duplicate-message-definition: Ignore i18n_extra folder
Browse files Browse the repository at this point in the history
Odoo exports translations grouped by "msgid" and delete duplicated

if you will not use odoo exports feature so you will need to manage manually the po file

It could be in i18n_extra in order to ignore the Odoo's normal flow

More info about OCA#122
  • Loading branch information
moylop260 committed Jan 30, 2025
1 parent 7ab8608 commit f8b0f43
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ options:

* po-duplicate-message-definition

- https://github.com/OCA/odoo-pre-commit-hooks/blob/v0.1.0/test_repo/broken_module/i18n/es.po#L17 Duplicate PO message definition `Branch` in lines 23, 29
- https://github.com/OCA/odoo-pre-commit-hooks/blob/v0.1.0/test_repo/broken_module/i18n/es.po#L35 Duplicate PO message definition `Message id toooooooooooooooooooooooooooo...` in lines 41
- https://github.com/OCA/odoo-pre-commit-hooks/blob/v0.1.0/test_repo/broken_module/i18n/es.po#L65 Duplicate PO message definition `One variable {variable1}` in lines 71
- https://github.com/OCA/odoo-pre-commit-hooks/blob/v0.1.0/test_repo/broken_module/i18n/es.po#L17 Duplicate PO message definition `Branch` in lines 23, 29. Odoo exports these items by msgid and delete one of them. Use the `i18n_extra` folder instead of `i18n` to ignore this message.
- https://github.com/OCA/odoo-pre-commit-hooks/blob/v0.1.0/test_repo/broken_module/i18n/es.po#L35 Duplicate PO message definition `Message id toooooooooooooooooooooooooooo...` in lines 41. Odoo exports these items by msgid and delete one of them. Use the `i18n_extra` folder instead of `i18n` to ignore this message.
- https://github.com/OCA/odoo-pre-commit-hooks/blob/v0.1.0/test_repo/broken_module/i18n/es.po#L65 Duplicate PO message definition `One variable {variable1}` in lines 71. Odoo exports these items by msgid and delete one of them. Use the `i18n_extra` folder instead of `i18n` to ignore this message.

* po-duplicate-model-definition

Expand Down
8 changes: 5 additions & 3 deletions src/oca_pre_commit_hooks/checks_odoo_module_po.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ def check_po(self):
if entry.obsolete:
continue

# po_duplicate_message_definition
if self.is_message_enabled("po-duplicate-message-definition"):
# Ignore i18n_extra https://github.com/OCA/odoo-pre-commit-hooks/issues/122
if self.is_message_enabled("po-duplicate-message-definition") and self.data_section != "i18n_extra":
duplicated[hash(entry.msgid)].append(entry)

if self.is_message_enabled("po-duplicate-model-definition"):
Expand All @@ -351,7 +351,9 @@ def check_po(self):
msg_id_short = f"{msg_id_short}..."
self.register_error(
code="po-duplicate-message-definition",
message=f"Duplicate PO message definition `{msg_id_short}` in lines {duplicated_str}",
message=f"Duplicate PO message definition `{msg_id_short}` in lines {duplicated_str}. "
"Odoo exports these items by msgid and delete one of them. "
"Use the `i18n_extra` folder instead of `i18n` to ignore this message.",
filepath=self.filename_short,
line=self._get_po_line_number(entries[0]),
)
Expand Down
25 changes: 25 additions & 0 deletions test_repo/broken_module/i18n_extra/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
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 <moylop260@vauxoo.com>\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: broken_module
#: model:ir.model.fields,field_description5:broken_module.field_wizard_description5
#, python-format
msgid "'Duplicate PO message definition' ignored for i18n_extra"
msgstr "'translation' 1"

#. module: broken_module
#: model:ir.model.fields,field_description10:broken_module.field_wizard_description10
#, python-format
msgid "'Duplicate PO message definition' ignored for i18n_extra"
msgstr "'translation' 2"

0 comments on commit f8b0f43

Please sign in to comment.