From 6a64afad537b064d70ffed406bbfdd0c317d6593 Mon Sep 17 00:00:00 2001 From: dariomesic Date: Tue, 28 Oct 2025 17:30:01 +0100 Subject: [PATCH 1/2] Fix: Implement smarter reference comparison for i18n --- sphinx/transforms/i18n.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sphinx/transforms/i18n.py b/sphinx/transforms/i18n.py index 570154185e9..b87894dbb7d 100644 --- a/sphinx/transforms/i18n.py +++ b/sphinx/transforms/i18n.py @@ -135,10 +135,9 @@ def compare_references( warning_msg: str, ) -> None: """Warn about mismatches between references in original and translated content.""" - # FIXME: could use a smarter strategy than len(old_refs) == len(new_refs) - if not self.noqa and len(old_refs) != len(new_refs): - old_ref_rawsources = [ref.rawsource for ref in old_refs] - new_ref_rawsources = [ref.rawsource for ref in new_refs] + old_ref_rawsources = [ref.rawsource for ref in old_refs] + new_ref_rawsources = [ref.rawsource for ref in new_refs] + if not self.noqa and old_ref_rawsources != new_ref_rawsources: logger.warning( warning_msg.format(old_ref_rawsources, new_ref_rawsources), location=self.node, From 22dbacadb9329880514ea6e1636bc58830438e0c Mon Sep 17 00:00:00 2001 From: dariomesic Date: Tue, 28 Oct 2025 17:41:43 +0100 Subject: [PATCH 2/2] Tests: Update intl test to expect new reference warning --- tests/test_intl/test_intl.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_intl/test_intl.py b/tests/test_intl/test_intl.py index 2375c1a6687..e6a2737746f 100644 --- a/tests/test_intl/test_intl.py +++ b/tests/test_intl/test_intl.py @@ -192,6 +192,12 @@ def test_text_inconsistency_warnings(app): 'translated': '\\[\\]', } + warning_fmt + % { + 'reftype': 'citation references', + 'original': "\\['\\[ref2\\]_'\\]", + 'translated': "\\['\\[ref3\\]_'\\]", + } + + warning_fmt % { 'reftype': 'references', 'original': "\\['reference_'\\]",