diff --git a/CHANGES b/CHANGES index 2207ba30f..44a246bf5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,19 @@ +Release 1.2 (in development) +============================ + +Features added +-------------- + +Incompatible changes +-------------------- + +Bugs fixed +---------- + +* #1265: Fix i18n: crash when translating section name that is pointed from + named target. + + Release 1.2 beta2 (released Sep 17, 2013) ========================================= diff --git a/sphinx/transforms.py b/sphinx/transforms.py index cf1040cfd..338d47392 100644 --- a/sphinx/transforms.py +++ b/sphinx/transforms.py @@ -242,6 +242,13 @@ class Locale(Transform): self.document.note_implicit_target( section_node, section_node) + # replace target's refname to new target name + def is_named_target(node): + return isinstance(node, nodes.target) and \ + node.get('refname') == old_name + for old_target in self.document.traverse(is_named_target): + old_target['refname'] = new_name + processed = True # glossary terms update refid diff --git a/tests/roots/test-intl/label_target.po b/tests/roots/test-intl/label_target.po index 2e600f6d7..69844016f 100644 --- a/tests/roots/test-intl/label_target.po +++ b/tests/roots/test-intl/label_target.po @@ -50,3 +50,9 @@ msgid "" msgstr "" "`X DUPLICATED SUB SECTION`_ IS BROKEN LINK." +msgid "label bridged target section" +msgstr "X LABEL BRIDGED TARGET SECTION" + +msgid "`bridge label`_ is not translatable but linked to translated section title." +msgstr "X `bridge label`_ IS NOT TRANSLATABLE BUT LINKED TO TRANSLATED SECTION TITLE." + diff --git a/tests/roots/test-intl/label_target.txt b/tests/roots/test-intl/label_target.txt index b597abe73..635de8470 100644 --- a/tests/roots/test-intl/label_target.txt +++ b/tests/roots/test-intl/label_target.txt @@ -47,8 +47,18 @@ duplicated sub section ------------------------ .. This section have no label, but the section was a duplicate name. -.. THis case, a duplicated target id is generated by docutils. +.. This case, a duplicated target id is generated by docutils. .. There is no way to link to this section's duplicated id like ``id2`` by .. using formal reStructuredText markup. + +.. _bridge label: `label bridged target section`_ + +label bridged target section +============================= + +.. This section is targeted through label definition. + +`bridge label`_ is not translatable but linked to translated section title. + diff --git a/tests/test_intl.py b/tests/test_intl.py index 67ab95781..13cdc84a4 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -420,7 +420,7 @@ def test_i18n_role_xref(app): @with_intl_app(buildername='xml', warning=warnfile) def test_i18n_label_target(app): - # regression test for #1193 + # regression test for #1193, #1265 app.builder.build(['label_target']) et = ElementTree.parse(app.outdir / 'label_target.xml') secs = et.findall('section') @@ -455,6 +455,14 @@ def test_i18n_label_target(app): texts=['`X DUPLICATED SUB SECTION`_', 'IS BROKEN LINK.'], refs=[]) + para3 = secs[3].findall('paragraph') + assert_elem( + para3[0], + texts=['X', 'bridge label', + 'IS NOT TRANSLATABLE BUT LINKED TO TRANSLATED ' + + 'SECTION TITLE.'], + refs=['label-bridged-target-section']) + @with_intl_app(buildername='text', warning=warnfile) def test_i18n_glossary_terms_inconsistency(app):