mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Display reference texts of original and translated messages
This commit is contained in:
parent
46bf9ab4a0
commit
ff88c8b730
@ -273,7 +273,11 @@ class Locale(SphinxTransform):
|
|||||||
old_foot_refs = node.traverse(is_autonumber_footnote_ref)
|
old_foot_refs = node.traverse(is_autonumber_footnote_ref)
|
||||||
new_foot_refs = patch.traverse(is_autonumber_footnote_ref)
|
new_foot_refs = patch.traverse(is_autonumber_footnote_ref)
|
||||||
if len(old_foot_refs) != len(new_foot_refs):
|
if len(old_foot_refs) != len(new_foot_refs):
|
||||||
logger.warning('inconsistent footnote references in translated message',
|
old_foot_ref_rawsources = [ref.rawsource for ref in old_foot_refs]
|
||||||
|
new_foot_ref_rawsources = [ref.rawsource for ref in new_foot_refs]
|
||||||
|
logger.warning('inconsistent footnote references in translated message.' +
|
||||||
|
' original: {0}, translated: {1}'
|
||||||
|
.format(old_foot_ref_rawsources, new_foot_ref_rawsources),
|
||||||
location=node)
|
location=node)
|
||||||
old_foot_namerefs = {} # type: Dict[unicode, List[nodes.footnote_reference]]
|
old_foot_namerefs = {} # type: Dict[unicode, List[nodes.footnote_reference]]
|
||||||
for r in old_foot_refs:
|
for r in old_foot_refs:
|
||||||
@ -309,7 +313,11 @@ class Locale(SphinxTransform):
|
|||||||
old_refs = node.traverse(is_refnamed_ref)
|
old_refs = node.traverse(is_refnamed_ref)
|
||||||
new_refs = patch.traverse(is_refnamed_ref)
|
new_refs = patch.traverse(is_refnamed_ref)
|
||||||
if len(old_refs) != len(new_refs):
|
if len(old_refs) != len(new_refs):
|
||||||
logger.warning('inconsistent references in translated message',
|
old_ref_rawsources = [ref.rawsource for ref in old_refs]
|
||||||
|
new_ref_rawsources = [ref.rawsource for ref in new_refs]
|
||||||
|
logger.warning('inconsistent references in translated message.' +
|
||||||
|
' original: {0}, translated: {1}'
|
||||||
|
.format(old_ref_rawsources, new_ref_rawsources),
|
||||||
location=node)
|
location=node)
|
||||||
old_ref_names = [r['refname'] for r in old_refs]
|
old_ref_names = [r['refname'] for r in old_refs]
|
||||||
new_ref_names = [r['refname'] for r in new_refs]
|
new_ref_names = [r['refname'] for r in new_refs]
|
||||||
@ -336,7 +344,11 @@ class Locale(SphinxTransform):
|
|||||||
new_foot_refs = patch.traverse(is_refnamed_footnote_ref)
|
new_foot_refs = patch.traverse(is_refnamed_footnote_ref)
|
||||||
refname_ids_map = {}
|
refname_ids_map = {}
|
||||||
if len(old_foot_refs) != len(new_foot_refs):
|
if len(old_foot_refs) != len(new_foot_refs):
|
||||||
logger.warning('inconsistent footnote references in translated message',
|
old_foot_ref_rawsources = [ref.rawsource for ref in old_foot_refs]
|
||||||
|
new_foot_ref_rawsources = [ref.rawsource for ref in new_foot_refs]
|
||||||
|
logger.warning('inconsistent footnote references in translated message.' +
|
||||||
|
' original: {0}, translated: {1}'
|
||||||
|
.format(old_foot_ref_rawsources, new_foot_ref_rawsources),
|
||||||
location=node)
|
location=node)
|
||||||
for old in old_foot_refs:
|
for old in old_foot_refs:
|
||||||
refname_ids_map[old["refname"]] = old["ids"]
|
refname_ids_map[old["refname"]] = old["ids"]
|
||||||
@ -354,7 +366,11 @@ class Locale(SphinxTransform):
|
|||||||
new_cite_refs = patch.traverse(is_citation_ref)
|
new_cite_refs = patch.traverse(is_citation_ref)
|
||||||
refname_ids_map = {}
|
refname_ids_map = {}
|
||||||
if len(old_cite_refs) != len(new_cite_refs):
|
if len(old_cite_refs) != len(new_cite_refs):
|
||||||
logger.warning('inconsistent citation references in translated message',
|
old_cite_ref_rawsources = [ref.rawsource for ref in old_cite_refs]
|
||||||
|
new_cite_ref_rawsources = [ref.rawsource for ref in new_cite_refs]
|
||||||
|
logger.warning('inconsistent citation references in translated message.' +
|
||||||
|
' original: {0}, translated: {1}'
|
||||||
|
.format(old_cite_ref_rawsources, new_cite_ref_rawsources),
|
||||||
location=node)
|
location=node)
|
||||||
for old in old_cite_refs:
|
for old in old_cite_refs:
|
||||||
refname_ids_map[old["refname"]] = old["ids"]
|
refname_ids_map[old["refname"]] = old["ids"]
|
||||||
@ -370,7 +386,11 @@ class Locale(SphinxTransform):
|
|||||||
new_refs = patch.traverse(addnodes.pending_xref)
|
new_refs = patch.traverse(addnodes.pending_xref)
|
||||||
xref_reftarget_map = {}
|
xref_reftarget_map = {}
|
||||||
if len(old_refs) != len(new_refs):
|
if len(old_refs) != len(new_refs):
|
||||||
logger.warning('inconsistent term references in translated message',
|
old_ref_rawsources = [ref.rawsource for ref in old_refs]
|
||||||
|
new_ref_rawsources = [ref.rawsource for ref in new_refs]
|
||||||
|
logger.warning('inconsistent term references in translated message.' +
|
||||||
|
' original: {0}, translated: {1}'
|
||||||
|
.format(old_ref_rawsources, new_ref_rawsources),
|
||||||
location=node)
|
location=node)
|
||||||
|
|
||||||
def get_ref_key(node):
|
def get_ref_key(node):
|
||||||
|
@ -192,11 +192,29 @@ def test_text_inconsistency_warnings(app, warning):
|
|||||||
|
|
||||||
warnings = getwarning(warning)
|
warnings = getwarning(warning)
|
||||||
warning_fmt = u'.*/refs_inconsistency.txt:\\d+: ' \
|
warning_fmt = u'.*/refs_inconsistency.txt:\\d+: ' \
|
||||||
u'WARNING: inconsistent %s in translated message\n'
|
u'WARNING: inconsistent %(reftype)s in translated message.' \
|
||||||
|
u' original: %(original)s, translated: %(translated)s\n'
|
||||||
expected_warning_expr = (
|
expected_warning_expr = (
|
||||||
warning_fmt % 'footnote references' +
|
warning_fmt % {
|
||||||
warning_fmt % 'references' +
|
u'reftype': u'footnote references',
|
||||||
warning_fmt % 'references')
|
u'original': u"\['\[#\]_'\]",
|
||||||
|
u'translated': u"\[\]"
|
||||||
|
} +
|
||||||
|
warning_fmt % {
|
||||||
|
u'reftype': u'footnote references',
|
||||||
|
u'original': u"\['\[100\]_'\]",
|
||||||
|
u'translated': u"\[\]"
|
||||||
|
} +
|
||||||
|
warning_fmt % {
|
||||||
|
u'reftype': u'references',
|
||||||
|
u'original': u"\['reference_'\]",
|
||||||
|
u'translated': u"\['reference_', 'reference_'\]"
|
||||||
|
} +
|
||||||
|
warning_fmt % {
|
||||||
|
u'reftype': u'references',
|
||||||
|
u'original': u"\[\]",
|
||||||
|
u'translated': u"\['`I18N WITH REFS INCONSISTENCY`_'\]"
|
||||||
|
})
|
||||||
assert_re_search(expected_warning_expr, warnings)
|
assert_re_search(expected_warning_expr, warnings)
|
||||||
|
|
||||||
expected_citation_warning_expr = (
|
expected_citation_warning_expr = (
|
||||||
@ -281,7 +299,8 @@ def test_text_glossary_term_inconsistencies(app, warning):
|
|||||||
warnings = getwarning(warning)
|
warnings = getwarning(warning)
|
||||||
expected_warning_expr = (
|
expected_warning_expr = (
|
||||||
u'.*/glossary_terms_inconsistency.txt:\\d+: '
|
u'.*/glossary_terms_inconsistency.txt:\\d+: '
|
||||||
u'WARNING: inconsistent term references in translated message\n')
|
u'WARNING: inconsistent term references in translated message.'
|
||||||
|
u" original: \[':term:`Some term`', ':term:`Some other term`'\], translated: \[':term:`SOME NEW TERM`'\]\n")
|
||||||
assert_re_search(expected_warning_expr, warnings)
|
assert_re_search(expected_warning_expr, warnings)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user