Merge pull request #6184 from tk0miya/6178_hidden_tocs

Fix #6178: i18n: Captions missing in translations for hidden TOCs
This commit is contained in:
Takeshi KOMIYA 2019-03-19 01:54:43 +09:00 committed by GitHub
commit 0af3012cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 0 deletions

View File

@ -35,6 +35,7 @@ Bugs fixed
* #6172: AttributeError is raised for old styled index nodes
* #4872: inheritance_diagram: correctly describe behavior of ``parts`` option in
docs, allow negative values.
* #6178: i18n: Captions missing in translations for hidden TOCs
Testing
--------

View File

@ -16,6 +16,7 @@ from os import path, walk, getenv
from time import time
from uuid import uuid4
from sphinx import addnodes
from sphinx.builders import Builder
from sphinx.domains.python import pairindextypes
from sphinx.errors import ThemeError
@ -142,6 +143,11 @@ class I18nBuilder(Builder):
# type: (str, nodes.document) -> None
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):
catalog.add(msg, node)

View File

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

View File

@ -30,3 +30,10 @@ CONTENTS
refs
section
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
expected_expr = '<meta content="I18N, SPHINX, MARKUP" name="keywords" />'
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