| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,13 @@ jobs: | |||
| 22 | 22 | ||
| 23 | 23 | steps: | |
| 24 | 24 | - uses: actions/checkout@v5 | |
| 25 | + - uses: actions/setup-python@v5 | ||
| 26 | + | ||
| 27 | + - name: Compile translations | ||
| 28 | + run: | | ||
| 29 | + pip install --upgrade pip | ||
| 30 | + pip install -r requirements.txt | ||
| 31 | + python babel_runner.py compile | ||
| 25 | 32 | ||
| 26 | 33 | - uses: hynek/build-and-inspect-python-package@v2 | |
| 27 | 34 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,7 +71,7 @@ jobs: | |||
| 71 | 71 | pip install -r requirements.txt | |
| 72 | 72 | - name: Remove locale file for testing | |
| 73 | 73 | shell: bash | |
| 74 | - run: rm -rf locales/pt_BR/ | ||
| 74 | + run: rm -rf python_docs_theme/locale/pt_BR/ | ||
| 75 | 75 | - run: python babel_runner.py extract | |
| 76 | 76 | - run: python babel_runner.py init -l pt_BR | |
| 77 | 77 | - run: python babel_runner.py update | |
@@ -80,10 +80,7 @@ jobs: | |||
| 80 | 80 | - run: python babel_runner.py compile -l pt_BR | |
| 81 | 81 | - name: Print .pot file | |
| 82 | 82 | shell: bash | |
| 83 | - run: cat locales/messages.pot | ||
| 83 | + run: cat python_docs_theme/locale/python-docs-theme.pot | ||
| 84 | 84 | - name: Print .po file | |
| 85 | 85 | shell: bash | |
| 86 | - run: cat locales/pt_BR/LC_MESSAGES/messages.po | ||
| 87 | - - name: list files in locales dir | ||
| 88 | - shell: bash | ||
| 89 | - run: ls -R locales/ | ||
| 86 | + run: cat python_docs_theme/locale/pt_BR/LC_MESSAGES/python-docs-theme.po | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | - #!/usr/bin/venv python3 | ||
| 2 | 1 | """Script for handling translations with Babel""" | |
| 2 | + | ||
| 3 | 3 | from __future__ import annotations | |
| 4 | 4 | ||
| 5 | 5 | import argparse | |
@@ -8,18 +8,18 @@ | |||
| 8 | 8 | import tomllib | |
| 9 | 9 | from pathlib import Path | |
| 10 | 10 | ||
| 11 | - PROJECT_DIR = Path(__file__).resolve().parent | ||
| 12 | - PYPROJECT_TOML = PROJECT_DIR / "pyproject.toml" | ||
| 13 | - INIT_PY = PROJECT_DIR / "python_docs_theme" / "__init__.py" | ||
| 14 | - | ||
| 15 | 11 | # Global variables used by pybabel below (paths relative to PROJECT_DIR) | |
| 16 | - DOMAIN = "messages" | ||
| 12 | + DOMAIN = "python-docs-theme" | ||
| 17 | 13 | COPYRIGHT_HOLDER = "Python Software Foundation" | |
| 18 | - LOCALES_DIR = "locales" | ||
| 19 | - POT_FILE = Path(LOCALES_DIR, f"{DOMAIN}.pot") | ||
| 20 | 14 | SOURCE_DIR = "python_docs_theme" | |
| 21 | 15 | MAPPING_FILE = ".babel.cfg" | |
| 22 | 16 | ||
| 17 | + PROJECT_DIR = Path(__file__).resolve().parent | ||
| 18 | + PYPROJECT_TOML = Path(PROJECT_DIR, "pyproject.toml") | ||
| 19 | + INIT_PY = PROJECT_DIR / SOURCE_DIR / "__init__.py" | ||
| 20 | + LOCALES_DIR = Path(f"{SOURCE_DIR}", "locale") | ||
| 21 | + POT_FILE = Path(LOCALES_DIR, f"{DOMAIN}.pot") | ||
| 22 | + | ||
| 23 | 23 | ||
| 24 | 24 | def get_project_info() -> dict: | |
| 25 | 25 | """Retrieve project's info to populate the message catalog template""" | |
@@ -75,21 +75,32 @@ def init_locale(locale: str) -> None: | |||
| 75 | 75 | if pofile.exists(): | |
| 76 | 76 | print(f"There is already a message catalog for locale {locale}, skipping.") | |
| 77 | 77 | return | |
| 78 | - cmd = ["pybabel", "init", "-i", POT_FILE, "-d", LOCALES_DIR, "-l", locale] | ||
| 78 | + cmd = [ | ||
| 79 | + "pybabel", | ||
| 80 | + "init", | ||
| 81 | + "-i", | ||
| 82 | + POT_FILE, | ||
| 83 | + "-d", | ||
| 84 | + LOCALES_DIR, | ||
| 85 | + "-D", | ||
| 86 | + DOMAIN, | ||
| 87 | + "-l", | ||
| 88 | + locale, | ||
| 89 | + ] | ||
| 79 | 90 | subprocess.run(cmd, cwd=PROJECT_DIR, check=True) | |
| 80 | 91 | ||
| 81 | 92 | ||
| 82 | 93 | def update_catalogs(locale: str) -> None: | |
| 83 | 94 | """Update translations from existing message catalogs""" | |
| 84 | - cmd = ["pybabel", "update", "-i", POT_FILE, "-d", LOCALES_DIR] | ||
| 95 | + cmd = ["pybabel", "update", "-i", POT_FILE, "-d", LOCALES_DIR, "-D", DOMAIN] | ||
| 85 | 96 | if locale: | |
| 86 | 97 | cmd.extend(["-l", locale]) | |
| 87 | 98 | subprocess.run(cmd, cwd=PROJECT_DIR, check=True) | |
| 88 | 99 | ||
| 89 | 100 | ||
| 90 | 101 | def compile_catalogs(locale: str) -> None: | |
| 91 | 102 | """Compile existing message catalogs""" | |
| 92 | - cmd = ["pybabel", "compile", "-d", LOCALES_DIR] | ||
| 103 | + cmd = ["pybabel", "compile", "-d", LOCALES_DIR, "-D", DOMAIN] | ||
| 93 | 104 | if locale: | |
| 94 | 105 | cmd.extend(["-l", locale]) | |
| 95 | 106 | subprocess.run(cmd, cwd=PROJECT_DIR, check=True) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | 3 | from pathlib import Path | |
| 4 | 4 | ||
| 5 | + from sphinx.locale import get_translation | ||
| 6 | + | ||
| 5 | 7 | TYPE_CHECKING = False | |
| 6 | 8 | if TYPE_CHECKING: | |
| 7 | 9 | from sphinx.application import Sphinx | |
@@ -10,12 +12,21 @@ | |||
| 10 | 12 | __version__ = "2025.5" | |
| 11 | 13 | ||
| 12 | 14 | THEME_PATH = Path(__file__).resolve().parent | |
| 15 | + LOCALE_DIR = THEME_PATH / "locale" | ||
| 16 | + MESSAGE_CATALOG_NAME = "python-docs-theme" | ||
| 13 | 17 | ||
| 14 | 18 | ||
| 15 | 19 | def setup(app: Sphinx) -> ExtensionMetadata: | |
| 16 | 20 | app.require_sphinx("7.3") | |
| 17 | 21 | ||
| 18 | 22 | app.add_html_theme("python_docs_theme", str(THEME_PATH)) | |
| 23 | + 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 | + app.connect("html-page-context", add_translation_to_context) | ||
| 19 | 30 | ||
| 20 | 31 | return { | |
| 21 | 32 | "version": __version__, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,127 @@ | |||
| 1 | + # Polish (Poland) translations for python-docs-theme. | ||
| 2 | + # Copyright (C) 2025 Python Software Foundation | ||
| 3 | + # This file is distributed under the same license as the python-docs-theme | ||
| 4 | + # project. | ||
| 5 | + # Stan Ulbrych, 2025. | ||
| 6 | + # | ||
| 7 | + msgid "" | ||
| 8 | + msgstr "" | ||
| 9 | + "Project-Id-Version: python-docs-theme 2025.5\n" | ||
| 10 | + "Report-Msgid-Bugs-To: https://github.com/python/python-docs-theme/issues\n" | ||
| 11 | + "POT-Creation-Date: 2025-08-07 19:09+0200\n" | ||
| 12 | + "PO-Revision-Date: 2025-08-07 15:11+0200\n" | ||
| 13 | + "Last-Translator: Stan Ulbrych \n" | ||
| 14 | + "Language: pl\n" | ||
| 15 | + "Language-Team: pl <LL@li.org>\n" | ||
| 16 | + "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && " | ||
| 17 | + "(n%100<10 || n%100>=20) ? 1 : 2);\n" | ||
| 18 | + "MIME-Version: 1.0\n" | ||
| 19 | + "Content-Type: text/plain; charset=utf-8\n" | ||
| 20 | + "Content-Transfer-Encoding: 8bit\n" | ||
| 21 | + "Generated-By: Babel 2.16.0\n" | ||
| 22 | + | ||
| 23 | + #: python_docs_theme/footerdonate.html:1 | ||
| 24 | + msgid "The Python Software Foundation is a non-profit corporation." | ||
| 25 | + msgstr "Python Software Foundation jest organizacją non-profit." | ||
| 26 | + | ||
| 27 | + #: python_docs_theme/footerdonate.html:2 | ||
| 28 | + msgid "Please donate." | ||
| 29 | + msgstr "Prosimy o wsparcie." | ||
| 30 | + | ||
| 31 | + #: python_docs_theme/layout.html:6 | ||
| 32 | + msgid "Navigation" | ||
| 33 | + msgstr "Nawigacja" | ||
| 34 | + | ||
| 35 | + #: python_docs_theme/layout.html:51 python_docs_theme/layout.html:111 | ||
| 36 | + msgid "Quick search" | ||
| 37 | + msgstr "Szybkie wyszukiwanie" | ||
| 38 | + | ||
| 39 | + #: python_docs_theme/layout.html:52 python_docs_theme/layout.html:112 | ||
| 40 | + msgid "Go" | ||
| 41 | + msgstr "Szukaj" | ||
| 42 | + | ||
| 43 | + #: python_docs_theme/layout.html:60 | ||
| 44 | + msgid "Theme" | ||
| 45 | + msgstr "Motyw" | ||
| 46 | + | ||
| 47 | + #: python_docs_theme/layout.html:62 | ||
| 48 | + msgid "Auto" | ||
| 49 | + msgstr "auto" | ||
| 50 | + | ||
| 51 | + #: python_docs_theme/layout.html:63 | ||
| 52 | + msgid "Light" | ||
| 53 | + msgstr "jasny" | ||
| 54 | + | ||
| 55 | + #: python_docs_theme/layout.html:64 | ||
| 56 | + msgid "Dark" | ||
| 57 | + msgstr "ciemny" | ||
| 58 | + | ||
| 59 | + #: python_docs_theme/layout.html:96 | ||
| 60 | + msgid "Menu" | ||
| 61 | + msgstr "Menu" | ||
| 62 | + | ||
| 63 | + #: python_docs_theme/layout.html:142 | ||
| 64 | + msgid "Copyright" | ||
| 65 | + msgstr "Prawa autorskie" | ||
| 66 | + | ||
| 67 | + #: python_docs_theme/layout.html:147 | ||
| 68 | + msgid "" | ||
| 69 | + "This page is licensed under the Python Software Foundation License " | ||
| 70 | + "Version 2." | ||
| 71 | + msgstr "" | ||
| 72 | + "Ta strona jest objęta licencją Python Software " | ||
| 73 | + "Foundation w wersji 2." | ||
| 74 | + | ||
| 75 | + #: python_docs_theme/layout.html:149 | ||
| 76 | + msgid "" | ||
| 77 | + "Examples, recipes, and other code in the documentation are additionally " | ||
| 78 | + "licensed under the Zero Clause BSD License." | ||
| 79 | + msgstr "" | ||
| 80 | + "Przykłady, przepisy i inny kod w dokumentacji są dodatkowo objęte " | ||
| 81 | + "licencją Zero Clause BSD." | ||
| 82 | + | ||
| 83 | + #: python_docs_theme/layout.html:152 | ||
| 84 | + #, python-format | ||
| 85 | + msgid "" | ||
| 86 | + "See <a href=\"%(license_file)s\">History and License</a> for more " | ||
| 87 | + "information." | ||
| 88 | + msgstr "" | ||
| 89 | + "Zobacz <a href=\"%(license_file)s\">Historię i licencję</a> aby uzyskać " | ||
| 90 | + "więcej informacji." | ||
| 91 | + | ||
| 92 | + #: python_docs_theme/layout.html:155 | ||
| 93 | + #, python-format | ||
| 94 | + msgid "Hosted on %(hosted_on)s." | ||
| 95 | + msgstr "Hostowane na %(hosted_on)s." | ||
| 96 | + | ||
| 97 | + #: python_docs_theme/layout.html:163 | ||
| 98 | + #, python-format | ||
| 99 | + msgid "Last updated on %(last_updated)s." | ||
| 100 | + msgstr "Ostatnia aktualizacja %(last_updated)s." | ||
| 101 | + | ||
| 102 | + #: python_docs_theme/layout.html:166 | ||
| 103 | + #, python-format | ||
| 104 | + msgid "<a href=\"%(theme_issues_url)s\">Found a bug</a>?" | ||
| 105 | + msgstr "<a href=\"%(theme_issues_url)s\">Znalazłeś(-aś) błąd</a>?" | ||
| 106 | + | ||
| 107 | + #: python_docs_theme/layout.html:170 | ||
| 108 | + #, python-format | ||
| 109 | + msgid "" | ||
| 110 | + "Created using <a href=\"https://www.sphinx-doc.org/\">Sphinx</a> " | ||
| 111 | + "%(sphinx_version)s." | ||
| 112 | + msgstr "" | ||
| 113 | + "Stworzone za pomocą <a href=\"https://www.sphinx-doc.org/\">Sphinx</a> " | ||
| 114 | + "%(sphinx_version)s." | ||
| 115 | + | ||
| 116 | + #: python_docs_theme/static/copybutton.js:30 | ||
| 117 | + #: python_docs_theme/static/copybutton.js:55 | ||
| 118 | + msgid "Copy" | ||
| 119 | + msgstr "Kopiuj" | ||
| 120 | + | ||
| 121 | + #: python_docs_theme/static/copybutton.js:31 | ||
| 122 | + msgid "Copy to clipboard" | ||
| 123 | + msgstr "Skopiuj do schowka" | ||
| 124 | + | ||
| 125 | + #: python_docs_theme/static/copybutton.js:53 | ||
| 126 | + msgid "Copied!" | ||
| 127 | + msgstr "Skopiowano!" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments