diff --git a/CHANGES b/CHANGES index 0c6f70d10..9608e3aa3 100644 --- a/CHANGES +++ b/CHANGES @@ -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 -------- diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index aace9bb49..092d64e2d 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -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) diff --git a/tests/roots/test-intl/index.po b/tests/roots/test-intl/index.po index 76ef049f0..a4646f1ec 100644 --- a/tests/roots/test-intl/index.po +++ b/tests/roots/test-intl/index.po @@ -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" diff --git a/tests/roots/test-intl/index.txt b/tests/roots/test-intl/index.txt index cd63b5ec3..1e09294f9 100644 --- a/tests/roots/test-intl/index.txt +++ b/tests/roots/test-intl/index.txt @@ -30,3 +30,10 @@ CONTENTS refs section topic + +.. toctree:: + :maxdepth: 2 + :caption: Hidden Toc + :hidden: + + only diff --git a/tests/test_intl.py b/tests/test_intl.py index 35e8f6909..803e22a0f 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -617,6 +617,8 @@ def test_html_meta(app): assert expected_expr in result expected_expr = '' assert expected_expr in result + expected_expr = '

HIDDEN TOC

' + assert expected_expr in result @sphinx_intl