FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix translation of html pages by StanFromIreland · Pull Request #263 · python/python-docs-theme · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .po  (7) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
26 changes: 21 additions & 5 deletions python_docs_theme/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Any

from sphinx.application import Sphinx
from sphinx.util.typing import ExtensionMetadata

Expand All @@ -16,16 +18,30 @@
MESSAGE_CATALOG_NAME = "python-docs-theme"


def add_translation_to_context(
app: Sphinx,
pagename: str,
templatename: str,
context: dict[str, Any],
doctree: None,
) -> None:
theme_gettext = get_translation(MESSAGE_CATALOG_NAME)
sphinx_gettext = get_translation("sphinx")

def combined(message: str) -> str:
translation = theme_gettext(message)
if translation == message:
return sphinx_gettext(message)
return translation

context["_"] = context["gettext"] = context["ngettext"] = combined


def setup(app: Sphinx) -> ExtensionMetadata:
app.require_sphinx("7.3")

app.add_html_theme("python_docs_theme", str(THEME_PATH))
app.add_message_catalog(MESSAGE_CATALOG_NAME, LOCALE_DIR)

def add_translation_to_context(app, pagename, templatename, context, doctree):
_ = get_translation(MESSAGE_CATALOG_NAME)
Comment thread
StanFromIreland marked this conversation as resolved.
context["_"] = context["gettext"] = context["ngettext"] = _

app.connect("html-page-context", add_translation_to_context)

return {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Translators:
# Cristián Maureira-Fredes, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: python-docs-theme 2025.5\n"
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Translators:
# Inada Naoki <songofacandy@gmail.com>, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: python-docs-theme 2025.5\n"
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Translators:
# Stan Ulbrych, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: python-docs-theme 2025.5\n"
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# Alexsey Batista da Silva, 2025
# Rafael Fontenelle <rffontenelle@gmail.com>, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: python-docs-theme 2025.5\n"
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Translators:
# Ege Akman, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: python-docs-theme 2025.5\n"
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Translators:
# 汇民 王 <whuim@qq.com>, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: python-docs-theme 2025.5\n"
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Translators:
# W. H. Wang <mattwang44@gmail.com>, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: python-docs-theme 2025.5\n"
Expand Down
Loading

Back | FazBrowse Home | New Git URL