Skip to content

Commit aeabc11

Browse files
authored
Implement smarter reference comparison for i18n (#14001)
1 parent 401d81f commit aeabc11

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

sphinx/transforms/i18n.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,9 @@ def compare_references(
135135
warning_msg: str,
136136
) -> None:
137137
"""Warn about mismatches between references in original and translated content."""
138-
# FIXME: could use a smarter strategy than len(old_refs) == len(new_refs)
139-
if not self.noqa and len(old_refs) != len(new_refs):
140-
old_ref_rawsources = [ref.rawsource for ref in old_refs]
141-
new_ref_rawsources = [ref.rawsource for ref in new_refs]
138+
old_ref_rawsources = [ref.rawsource for ref in old_refs]
139+
new_ref_rawsources = [ref.rawsource for ref in new_refs]
140+
if not self.noqa and old_ref_rawsources != new_ref_rawsources:
142141
logger.warning(
143142
warning_msg.format(old_ref_rawsources, new_ref_rawsources),
144143
location=self.node,

tests/test_intl/test_intl.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ def test_text_inconsistency_warnings(app):
192192
'translated': '\\[\\]',
193193
}
194194
+ warning_fmt
195+
% {
196+
'reftype': 'citation references',
197+
'original': "\\['\\[ref2\\]_'\\]",
198+
'translated': "\\['\\[ref3\\]_'\\]",
199+
}
200+
+ warning_fmt
195201
% {
196202
'reftype': 'references',
197203
'original': "\\['reference_'\\]",

0 commit comments

Comments
 (0)