mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix :term: doesn't link to glossary if term text translated. refs #1090
This commit is contained in:
parent
9735ec0a74
commit
a86ea846e2
@ -297,6 +297,16 @@ class Locale(Transform):
|
|||||||
if refname in refname_ids_map:
|
if refname in refname_ids_map:
|
||||||
new["ids"] = refname_ids_map[refname]
|
new["ids"] = refname_ids_map[refname]
|
||||||
|
|
||||||
|
# Original pending_xref['reftarget'] contain not-translated
|
||||||
|
# target name, new pending_xref must use original one.
|
||||||
|
old_refs = node.traverse(addnodes.pending_xref)
|
||||||
|
new_refs = patch.traverse(addnodes.pending_xref)
|
||||||
|
if len(old_refs) != len(new_refs):
|
||||||
|
env.warn_node('inconsistent term references in '
|
||||||
|
'translated message', node)
|
||||||
|
for old, new in zip(old_refs, new_refs):
|
||||||
|
new['reftarget'] = old['reftarget']
|
||||||
|
|
||||||
# update leaves
|
# update leaves
|
||||||
for child in patch.children:
|
for child in patch.children:
|
||||||
child.parent = node
|
child.parent = node
|
||||||
|
@ -12,3 +12,5 @@
|
|||||||
definition_terms
|
definition_terms
|
||||||
figure_caption
|
figure_caption
|
||||||
index_entries
|
index_entries
|
||||||
|
glossary_terms
|
||||||
|
glossary_terms_inconsistency
|
||||||
|
@ -20,13 +20,16 @@ msgid "i18n with glossary terms"
|
|||||||
msgstr "I18N WITH GLOSSARY TERMS"
|
msgstr "I18N WITH GLOSSARY TERMS"
|
||||||
|
|
||||||
msgid "Some term"
|
msgid "Some term"
|
||||||
msgstr "SOME TERM"
|
msgstr "SOME NEW TERM"
|
||||||
|
|
||||||
msgid "The corresponding glossary"
|
msgid "The corresponding glossary"
|
||||||
msgstr "THE CORRESPONDING GLOSSARY"
|
msgstr "THE CORRESPONDING GLOSSARY"
|
||||||
|
|
||||||
msgid "Some other term"
|
msgid "Some other term"
|
||||||
msgstr "SOME OTHER TERM"
|
msgstr "SOME OTHER NEW TERM"
|
||||||
|
|
||||||
msgid "The corresponding glossary #2"
|
msgid "The corresponding glossary #2"
|
||||||
msgstr "THE CORRESPONDING GLOSSARY #2"
|
msgstr "THE CORRESPONDING GLOSSARY #2"
|
||||||
|
|
||||||
|
msgid "link to :term:`Some term`."
|
||||||
|
msgstr "LINK TO :term:`SOME NEW TERM`."
|
||||||
|
@ -11,3 +11,4 @@ i18n with glossary terms
|
|||||||
Some other term
|
Some other term
|
||||||
The corresponding glossary #2
|
The corresponding glossary #2
|
||||||
|
|
||||||
|
link to :term:`Some term`.
|
||||||
|
23
tests/roots/test-intl/glossary_terms_inconsistency.po
Normal file
23
tests/roots/test-intl/glossary_terms_inconsistency.po
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) 2012, foof
|
||||||
|
# This file is distributed under the same license as the foo package.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
#
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: sphinx 1.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2013-01-29 14:10\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
msgid "i18n with glossary terms inconsistency"
|
||||||
|
msgstr "I18N WITH GLOSSARY TERMS INCONSISTENCY"
|
||||||
|
|
||||||
|
msgid "link to :term:`Some term` and :term:`Some other term`."
|
||||||
|
msgstr "LINK TO :term:`SOME NEW TERM`."
|
6
tests/roots/test-intl/glossary_terms_inconsistency.txt
Normal file
6
tests/roots/test-intl/glossary_terms_inconsistency.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
:tocdepth: 2
|
||||||
|
|
||||||
|
i18n with glossary terms inconsistency
|
||||||
|
======================================
|
||||||
|
|
||||||
|
1. link to :term:`Some term` and :term:`Some other term`.
|
@ -252,20 +252,43 @@ def test_i18n_definition_terms(app):
|
|||||||
assert result == expect
|
assert result == expect
|
||||||
|
|
||||||
|
|
||||||
@with_intl_app(buildername='text')
|
@with_intl_app(buildername='text', warning=warnfile)
|
||||||
def test_i18n_glossary_terms(app):
|
def test_i18n_glossary_terms(app):
|
||||||
# regression test for #1090
|
# regression test for #1090
|
||||||
|
app.builddir.rmtree(True) #for warnings acceleration
|
||||||
app.builder.build(['glossary_terms'])
|
app.builder.build(['glossary_terms'])
|
||||||
result = (app.outdir / 'glossary_terms.txt').text(encoding='utf-8')
|
result = (app.outdir / 'glossary_terms.txt').text(encoding='utf-8')
|
||||||
expect = (u"\nI18N WITH GLOSSARY TERMS"
|
expect = (u"\nI18N WITH GLOSSARY TERMS"
|
||||||
u"\n************************\n"
|
u"\n************************\n"
|
||||||
u"\nSOME TERM"
|
u"\nSOME NEW TERM"
|
||||||
u"\n THE CORRESPONDING GLOSSARY\n"
|
u"\n THE CORRESPONDING GLOSSARY\n"
|
||||||
u"\nSOME OTHER TERM"
|
u"\nSOME OTHER NEW TERM"
|
||||||
u"\n THE CORRESPONDING GLOSSARY #2\n")
|
u"\n THE CORRESPONDING GLOSSARY #2\n"
|
||||||
|
u"\nLINK TO *SOME NEW TERM*.\n")
|
||||||
assert result == expect
|
assert result == expect
|
||||||
|
|
||||||
|
warnings = warnfile.getvalue().replace(os.sep, '/')
|
||||||
|
assert 'term not in glossary' not in warnings
|
||||||
|
|
||||||
|
|
||||||
|
@with_intl_app(buildername='text', warning=warnfile)
|
||||||
|
def test_i18n_glossary_terms_inconsistency(app):
|
||||||
|
# regression test for #1090
|
||||||
|
app.builddir.rmtree(True) #for warnings acceleration
|
||||||
|
app.builder.build(['glossary_terms_inconsistency'])
|
||||||
|
result = (app.outdir / 'glossary_terms_inconsistency.txt'
|
||||||
|
).text(encoding='utf-8')
|
||||||
|
expect = (u"\nI18N WITH GLOSSARY TERMS INCONSISTENCY"
|
||||||
|
u"\n**************************************\n"
|
||||||
|
u"\n1. LINK TO *SOME NEW TERM*.\n")
|
||||||
|
assert result == expect
|
||||||
|
|
||||||
|
warnings = warnfile.getvalue().replace(os.sep, '/')
|
||||||
|
expected_warning_expr = (
|
||||||
|
u'.*/glossary_terms_inconsistency.txt:\\d+: '
|
||||||
|
u'WARNING: inconsistent term references in translated message\n')
|
||||||
|
assert re.search(expected_warning_expr, warnings)
|
||||||
|
|
||||||
|
|
||||||
@with_intl_app(buildername='text')
|
@with_intl_app(buildername='text')
|
||||||
def test_seealso(app):
|
def test_seealso(app):
|
||||||
|
Loading…
Reference in New Issue
Block a user