| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | 7 | TYPE_CHECKING = False | |
| 8 | 8 | if TYPE_CHECKING: | |
| 9 | + from typing import Any | ||
| 10 | + | ||
| 9 | 11 | from sphinx.application import Sphinx | |
| 10 | 12 | from sphinx.util.typing import ExtensionMetadata | |
| 11 | 13 | ||
@@ -16,16 +18,30 @@ | |||
| 16 | 18 | MESSAGE_CATALOG_NAME = "python-docs-theme" | |
| 17 | 19 | ||
| 18 | 20 | ||
| 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 | + | ||
| 19 | 40 | def setup(app: Sphinx) -> ExtensionMetadata: | |
| 20 | 41 | app.require_sphinx("7.3") | |
| 21 | 42 | ||
| 22 | 43 | app.add_html_theme("python_docs_theme", str(THEME_PATH)) | |
| 23 | 44 | 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 | - | ||
| 29 | 45 | app.connect("html-page-context", add_translation_to_context) | |
| 30 | 46 | ||
| 31 | 47 | return { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ | |||
| 7 | 7 | # Translators: | |
| 8 | 8 | # Cristián Maureira-Fredes, 2025 | |
| 9 | 9 | # | |
| 10 | - #, fuzzy | ||
| 11 | 10 | msgid "" | |
| 12 | 11 | msgstr "" | |
| 13 | 12 | "Project-Id-Version: python-docs-theme 2025.5\n" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ | |||
| 7 | 7 | # Translators: | |
| 8 | 8 | # Inada Naoki <songofacandy@gmail.com>, 2025 | |
| 9 | 9 | # | |
| 10 | - #, fuzzy | ||
| 11 | 10 | msgid "" | |
| 12 | 11 | msgstr "" | |
| 13 | 12 | "Project-Id-Version: python-docs-theme 2025.5\n" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ | |||
| 7 | 7 | # Translators: | |
| 8 | 8 | # Stan Ulbrych, 2025 | |
| 9 | 9 | # | |
| 10 | - #, fuzzy | ||
| 11 | 10 | msgid "" | |
| 12 | 11 | msgstr "" | |
| 13 | 12 | "Project-Id-Version: python-docs-theme 2025.5\n" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,6 @@ | |||
| 8 | 8 | # Alexsey Batista da Silva, 2025 | |
| 9 | 9 | # Rafael Fontenelle <rffontenelle@gmail.com>, 2025 | |
| 10 | 10 | # | |
| 11 | - #, fuzzy | ||
| 12 | 11 | msgid "" | |
| 13 | 12 | msgstr "" | |
| 14 | 13 | "Project-Id-Version: python-docs-theme 2025.5\n" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ | |||
| 7 | 7 | # Translators: | |
| 8 | 8 | # Ege Akman, 2025 | |
| 9 | 9 | # | |
| 10 | - #, fuzzy | ||
| 11 | 10 | msgid "" | |
| 12 | 11 | msgstr "" | |
| 13 | 12 | "Project-Id-Version: python-docs-theme 2025.5\n" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ | |||
| 7 | 7 | # Translators: | |
| 8 | 8 | # 汇民 王 <whuim@qq.com>, 2025 | |
| 9 | 9 | # | |
| 10 | - #, fuzzy | ||
| 11 | 10 | msgid "" | |
| 12 | 11 | msgstr "" | |
| 13 | 12 | "Project-Id-Version: python-docs-theme 2025.5\n" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ | |||
| 7 | 7 | # Translators: | |
| 8 | 8 | # W. H. Wang <mattwang44@gmail.com>, 2025 | |
| 9 | 9 | # | |
| 10 | - #, fuzzy | ||
| 11 | 10 | msgid "" | |
| 12 | 11 | msgstr "" | |
| 13 | 12 | "Project-Id-Version: python-docs-theme 2025.5\n" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments