Fix #6178: i18n: Captions missing in translations for hidden TOCs

This commit is contained in:
Takeshi KOMIYA 2019-03-17 15:03:13 +09:00
parent a95af4c195
commit 6698bd6b3f
5 changed files with 19 additions and 0 deletions

View File

@ -32,6 +32,7 @@ Bugs fixed
classes attribute refers missing citation (refs: #6147) classes attribute refers missing citation (refs: #6147)
* #2155: Support ``code`` directive * #2155: Support ``code`` directive
* C++, fix parsing of braced initializers. * C++, fix parsing of braced initializers.
* #6178: i18n: Captions missing in translations for hidden TOCs
Testing Testing
-------- --------

View File

@ -16,6 +16,7 @@ from os import path, walk, getenv
from time import time from time import time
from uuid import uuid4 from uuid import uuid4
from sphinx import addnodes
from sphinx.builders import Builder from sphinx.builders import Builder
from sphinx.domains.python import pairindextypes from sphinx.domains.python import pairindextypes
from sphinx.errors import ThemeError from sphinx.errors import ThemeError
@ -142,6 +143,11 @@ class I18nBuilder(Builder):
# type: (str, nodes.document) -> None # type: (str, nodes.document) -> None
catalog = self.catalogs[find_catalog(docname, self.config.gettext_compact)] catalog = self.catalogs[find_catalog(docname, self.config.gettext_compact)]
for toctree in self.env.tocs[docname].traverse(addnodes.toctree):
for node, msg in extract_messages(toctree):
node.uid = '' # type: ignore # Hack UUID model
catalog.add(msg, node)
for node, msg in extract_messages(doctree): for node, msg in extract_messages(doctree):
catalog.add(msg, node) catalog.add(msg, node)

View File

@ -19,6 +19,9 @@ msgstr ""
msgid "Table of Contents" msgid "Table of Contents"
msgstr "TABLE OF CONTENTS" msgstr "TABLE OF CONTENTS"
msgid "Hidden Toc"
msgstr "HIDDEN TOC"
msgid "testdata for i18n" msgid "testdata for i18n"
msgstr "TESTDATA FOR I18N" msgstr "TESTDATA FOR I18N"

View File

@ -30,3 +30,10 @@ CONTENTS
refs refs
section section
topic topic
.. toctree::
:maxdepth: 2
:caption: Hidden Toc
:hidden:
only

View File

@ -617,6 +617,8 @@ def test_html_meta(app):
assert expected_expr in result assert expected_expr in result
expected_expr = '<meta content="I18N, SPHINX, MARKUP" name="keywords" />' expected_expr = '<meta content="I18N, SPHINX, MARKUP" name="keywords" />'
assert expected_expr in result assert expected_expr in result
expected_expr = '<p class="caption"><span class="caption-text">HIDDEN TOC</span></p>'
assert expected_expr in result
@sphinx_intl @sphinx_intl