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, 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_'\\]",