pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/python-docs-theme/commit/fee2ae0dbf6251e5df36f621a605085d9f6aa0ec

anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-5efd63e783ac04bb.css" /> Fix translation of html pages (#263) · python/python-docs-theme@fee2ae0 · GitHub
Skip to content

Commit fee2ae0

Browse files
Fix translation of html pages (#263)
1 parent b87195c commit fee2ae0

8 files changed

Lines changed: 21 additions & 12 deletions

File tree

python_docs_theme/__init__.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
TYPE_CHECKING = False
88
if TYPE_CHECKING:
9+
from typing import Any
10+
911
from sphinx.application import Sphinx
1012
from sphinx.util.typing import ExtensionMetadata
1113

@@ -16,16 +18,30 @@
1618
MESSAGE_CATALOG_NAME = "python-docs-theme"
1719

1820

21+
def add_translation_to_context(
22+
app: Sphinx,
23+
pagename: str,
24+
templatename: str,
25+
context: dict[str, Any],
26+
doctree: None,
27+
) -> None:
28+
theme_gettext = get_translation(MESSAGE_CATALOG_NAME)
29+
sphinx_gettext = get_translation("sphinx")
30+
31+
def combined(message: str) -> str:
32+
translation = theme_gettext(message)
33+
if translation == message:
34+
return sphinx_gettext(message)
35+
return translation
36+
37+
context["_"] = context["gettext"] = context["ngettext"] = combined
38+
39+
1940
def setup(app: Sphinx) -> ExtensionMetadata:
2041
app.require_sphinx("7.3")
2142

2243
app.add_html_theme("python_docs_theme", str(THEME_PATH))
2344
app.add_message_catalog(MESSAGE_CATALOG_NAME, LOCALE_DIR)
24-
25-
def add_translation_to_context(app, pagename, templatename, context, doctree):
26-
_ = get_translation(MESSAGE_CATALOG_NAME)
27-
context["_"] = context["gettext"] = context["ngettext"] = _
28-
2945
app.connect("html-page-context", add_translation_to_context)
3046

3147
return {

python_docs_theme/locale/es/LC_MESSAGES/python-docs-theme.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# Translators:
88
# Cristián Maureira-Fredes, 2025
99
#
10-
#, fuzzy
1110
msgid ""
1211
msgstr ""
1312
"Project-Id-Version: python-docs-theme 2025.5\n"

python_docs_theme/locale/ja/LC_MESSAGES/python-docs-theme.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# Translators:
88
# Inada Naoki <songofacandy@gmail.com>, 2025
99
#
10-
#, fuzzy
1110
msgid ""
1211
msgstr ""
1312
"Project-Id-Version: python-docs-theme 2025.5\n"

python_docs_theme/locale/pl/LC_MESSAGES/python-docs-theme.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# Translators:
88
# Stan Ulbrych, 2025
99
#
10-
#, fuzzy
1110
msgid ""
1211
msgstr ""
1312
"Project-Id-Version: python-docs-theme 2025.5\n"

python_docs_theme/locale/pt_BR/LC_MESSAGES/python-docs-theme.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
# Alexsey Batista da Silva, 2025
99
# Rafael Fontenelle <rffontenelle@gmail.com>, 2025
1010
#
11-
#, fuzzy
1211
msgid ""
1312
msgstr ""
1413
"Project-Id-Version: python-docs-theme 2025.5\n"

python_docs_theme/locale/tr/LC_MESSAGES/python-docs-theme.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# Translators:
88
# Ege Akman, 2025
99
#
10-
#, fuzzy
1110
msgid ""
1211
msgstr ""
1312
"Project-Id-Version: python-docs-theme 2025.5\n"

python_docs_theme/locale/zh_CN/LC_MESSAGES/python-docs-theme.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# Translators:
88
# 汇民 王 <whuim@qq.com>, 2025
99
#
10-
#, fuzzy
1110
msgid ""
1211
msgstr ""
1312
"Project-Id-Version: python-docs-theme 2025.5\n"

python_docs_theme/locale/zh_TW/LC_MESSAGES/python-docs-theme.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# Translators:
88
# W. H. Wang <mattwang44@gmail.com>, 2025
99
#
10-
#, fuzzy
1110
msgid ""
1211
msgstr ""
1312
"Project-Id-Version: python-docs-theme 2025.5\n"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy