Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix translation of html pages#263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugovk merged 3 commits intopython:mainfromStanFromIreland:fix-translation
Sep 15, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletionspython_docs_theme/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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)
context["_"] = context["gettext"] = context["ngettext"] = _

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

return {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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

[8]ページ先頭

©2009-2025 Movatter.jp