Crash when translating indirect reference

Nozomu Kaneko avatarNozomu Kaneko created an issue

When I ran sphinx-build, I got an exception ValueError: <reference: <#text: 'Layout'>> is not in list. Full traceback is attached.

Here is a patch to reproduce the issue:

diff --git a/tests/roots/test-intl/indirect_reference.po b/tests/roots/test-intl/indirect_reference.po
new file mode 100644
--- /dev/null
+++ b/tests/roots/test-intl/indirect_reference.po
@@ -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: 2012-12-05 08:28\n"
+"PO-Revision-Date: 2013-10-02 17:07+0900\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 "Title"
+msgstr "Title in foo language"
+
+msgid "This is a `link`_."
+msgstr "THIS IS A `link`_"
diff --git a/tests/roots/test-intl/indirect_reference.txt b/tests/roots/test-intl/indirect_reference.txt
new file mode 100644
--- /dev/null
+++ b/tests/roots/test-intl/indirect_reference.txt
@@ -0,0 +1,11 @@
+:tocdepth: 2
+
+i18n with indirect reference
+============================
+
+Title
+-----
+
+This is a `link`_.
+
+.. _link: `Title`_
diff --git a/tests/test_intl.py b/tests/test_intl.py
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -640,3 +640,9 @@
     (app.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').write_bytes(mo)
     _, count, _ = app.env.update(app.config, app.srcdir, app.doctreedir, app)
     assert count == 1
+
+
+@with_intl_app(buildername='text')
+def test_i18n_indirect_reference(app):
+    app.builder.build(['indirect_reference'])
+    result = (app.outdir / 'indirect_reference.txt').text(encoding='utf-8')

Comments (7)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.