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` :confval:`suppress_warnings`
* C, added scope control directives, :rst:dir:`c:namespace`, * C, added scope control directives, :rst:dir:`c:namespace`,
:rst:dir:`c:namespace-push`, and :rst:dir:`c:namespace-pop`. :rst:dir:`c:namespace-push`, and :rst:dir:`c:namespace-pop`.
* #7466: autosummary: headings in generated documents are not translated
Bugs fixed Bugs fixed
---------- ----------

View File

@ -124,6 +124,11 @@ class AutosummaryRenderer:
self.env.filters['e'] = rst.escape self.env.filters['e'] = rst.escape
self.env.filters['underline'] = _underline 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: def exists(self, template_name: str) -> bool:
"""Check if template file exists.""" """Check if template file exists."""
try: try:

View File

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

View File

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