Merge pull request #7467 from tk0miya/7466_make_autosummary_headings_translatable

Fix #7466: autosummary: headings in generated documents are not translated
This commit is contained in:
Takeshi KOMIYA 2020-04-13 23:33:26 +09:00 committed by GitHub
commit 503a7c1b22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 5 deletions

View File

@ -21,6 +21,7 @@ Features added
:confval:`suppress_warnings`
* C, added scope control directives, :rst:dir:`c:namespace`,
:rst:dir:`c:namespace-push`, and :rst:dir:`c:namespace-pop`.
* #7466: autosummary: headings in generated documents are not translated
Bugs fixed
----------

View File

@ -124,6 +124,11 @@ class AutosummaryRenderer:
self.env.filters['e'] = rst.escape
self.env.filters['underline'] = _underline
if builder:
if builder.app.translator:
self.env.add_extension("jinja2.ext.i18n")
self.env.install_gettext_translations(builder.app.translator) # type: ignore
def exists(self, template_name: str) -> bool:
"""Check if template file exists."""
try:

View File

@ -8,7 +8,7 @@
.. automethod:: __init__
{% if methods %}
.. rubric:: Methods
.. rubric:: {{ _('Methods') }}
.. autosummary::
{% for item in methods %}
@ -19,7 +19,7 @@
{% block attributes %}
{% if attributes %}
.. rubric:: Attributes
.. rubric:: {{ _('Attributes') }}
.. autosummary::
{% for item in attributes %}

View File

@ -4,7 +4,7 @@
{% block functions %}
{% if functions %}
.. rubric:: Functions
.. rubric:: {{ _('Functions') }}
.. autosummary::
{% for item in functions %}
@ -15,7 +15,7 @@
{% block classes %}
{% if classes %}
.. rubric:: Classes
.. rubric:: {{ _('Classes') }}
.. autosummary::
{% for item in classes %}
@ -26,7 +26,7 @@
{% block exceptions %}
{% if exceptions %}
.. rubric:: Exceptions
.. rubric:: {{ _('Exceptions') }}
.. autosummary::
{% for item in exceptions %}