Skip to content

Commit 1be03ac

Browse files
Attempt
1 parent 5d07825 commit 1be03ac

File tree

4 files changed

+251
-3
lines changed

4 files changed

+251
-3
lines changed

babel_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/venv python3
1+
#!/usr/bin/env python3
22
"""Script for handling translations with Babel"""
33
from __future__ import annotations
44

@@ -15,9 +15,9 @@
1515
# Global variables used by pybabel below (paths relative to PROJECT_DIR)
1616
DOMAIN = "messages"
1717
COPYRIGHT_HOLDER = "Python Software Foundation"
18-
LOCALES_DIR = "locales"
19-
POT_FILE = Path(LOCALES_DIR, f"{DOMAIN}.pot")
2018
SOURCE_DIR = "python_docs_theme"
19+
LOCALES_DIR = Path(SOURCE_DIR, "locales")
20+
POT_FILE = Path(LOCALES_DIR, f"{DOMAIN}.pot")
2121
MAPPING_FILE = ".babel.cfg"
2222

2323

python_docs_theme/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from pathlib import Path
44

5+
import gettext
6+
57
TYPE_CHECKING = False
68
if TYPE_CHECKING:
79
from sphinx.application import Sphinx
@@ -12,10 +14,20 @@
1214
THEME_PATH = Path(__file__).resolve().parent
1315

1416

17+
def _setup_translations(app):
18+
language = app.config.language or 'en'
19+
try:
20+
translation = gettext.translation(domain="messages", localedir=str(THEME_PATH / "locales"), languages=[language])
21+
app.builder.templates.environment.install_gettext_translations(translation, newstyle=True)
22+
except FileNotFoundError:
23+
app.builder.templates.environment.install_gettext(lambda x: x, newstyle=True)
24+
25+
1526
def setup(app: Sphinx) -> ExtensionMetadata:
1627
app.require_sphinx("7.3")
1728

1829
app.add_html_theme("python_docs_theme", str(THEME_PATH))
30+
app.connect("builder-inited", _setup_translations)
1931

2032
return {
2133
"version": __version__,
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2025.
6+
#
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: python-docs-theme 2025.4.1\n"
10+
"Report-Msgid-Bugs-To: https://github.com/python/python-docs-theme/"
11+
"issues\n"
12+
"POT-Creation-Date: 2025-05-21 17:34+0100\n"
13+
"PO-Revision-Date: 2025-05-21 17:39+0100\n"
14+
"Last-Translator: Stan Ulbrych <[email protected]>\n"
15+
"Language-Team: pl_PL <[email protected]>\n"
16+
"Language: pl_PL\n"
17+
"MIME-Version: 1.0\n"
18+
"Content-Type: text/plain; charset=utf-8\n"
19+
"Content-Transfer-Encoding: 8bit\n"
20+
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && "
21+
"(n%100<10 || n%100>=20) ? 1 : 2);\n"
22+
"Generated-By: Babel 2.16.0\n"
23+
"X-Generator: Poedit 3.6\n"
24+
25+
#: python_docs_theme/footerdonate.html:1
26+
msgid "The Python Software Foundation is a non-profit corporation."
27+
msgstr "Python Software Foundation jest organizacją non-profit."
28+
29+
#: python_docs_theme/footerdonate.html:2
30+
msgid "Please donate."
31+
msgstr ""
32+
33+
#: python_docs_theme/layout.html:6
34+
msgid "Navigation"
35+
msgstr "Navigation"
36+
37+
#: python_docs_theme/layout.html:51 python_docs_theme/layout.html:111
38+
msgid "Quick search"
39+
msgstr "Szybkie wyszukiwanie"
40+
41+
#: python_docs_theme/layout.html:52 python_docs_theme/layout.html:112
42+
msgid "Go"
43+
msgstr "Idź"
44+
45+
#: python_docs_theme/layout.html:60
46+
msgid "Theme"
47+
msgstr ""
48+
49+
#: python_docs_theme/layout.html:62
50+
msgid "Auto"
51+
msgstr "Auto"
52+
53+
#: python_docs_theme/layout.html:63
54+
msgid "Light"
55+
msgstr "Jasny"
56+
57+
#: python_docs_theme/layout.html:64
58+
msgid "Dark"
59+
msgstr "Ciemny"
60+
61+
#: python_docs_theme/layout.html:96
62+
msgid "Menu"
63+
msgstr "Menu"
64+
65+
#: python_docs_theme/layout.html:142
66+
msgid "Copyright"
67+
msgstr ""
68+
69+
#: python_docs_theme/layout.html:147
70+
msgid ""
71+
"This page is licensed under the Python Software Foundation License "
72+
"Version 2."
73+
msgstr ""
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+
81+
#: python_docs_theme/layout.html:152
82+
#, python-format
83+
msgid ""
84+
"See <a href=\"%(license_file)s\">History and License</a> for more "
85+
"information."
86+
msgstr ""
87+
88+
#: python_docs_theme/layout.html:155
89+
#, python-format
90+
msgid "Hosted on %(hosted_on)s."
91+
msgstr ""
92+
93+
#: python_docs_theme/layout.html:163
94+
#, python-format
95+
msgid "Last updated on %(last_updated)s."
96+
msgstr ""
97+
98+
#: python_docs_theme/layout.html:166
99+
#, python-format
100+
msgid "<a href=\"%(theme_issues_url)s\">Found a bug</a>?"
101+
msgstr "<a href=\"%(theme_issues_url)s\">Znalazłeś błąd</a>?"
102+
103+
#: python_docs_theme/layout.html:170
104+
#, python-format
105+
msgid ""
106+
"Created using <a href=\"https://www.sphinx-doc.org/\">Sphinx</a> "
107+
"%(sphinx_version)s."
108+
msgstr ""
109+
"Stworzone przy użyciu <a href=\"https://www.sphinx-doc.org/\">Sphinx</"
110+
"a> %(sphinx_version)s."
111+
112+
#: python_docs_theme/static/copybutton.js:30
113+
#: python_docs_theme/static/copybutton.js:55
114+
msgid "Copy"
115+
msgstr "Kopiuj"
116+
117+
#: python_docs_theme/static/copybutton.js:31
118+
msgid "Copy to clipboard"
119+
msgstr "Skopiuj do schowka"
120+
121+
#: python_docs_theme/static/copybutton.js:53
122+
msgid "Copied!"
123+
msgstr "Skopiowano!"
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Portuguese (Brazil) 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+
# Rafael Fontenelle <[email protected]>, 2025.
6+
#
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: python-docs-theme 2024.6\n"
10+
"Report-Msgid-Bugs-To: https://github.com/python/python-docs-theme/issues\n"
11+
"POT-Creation-Date: 2024-08-03 15:53-0300\n"
12+
"PO-Revision-Date: 2024-08-03 15:53-0300\n"
13+
"Last-Translator: Rafael Fontenelle <[email protected]>\n"
14+
"Language: pt_BR\n"
15+
"Language-Team: Brazilian Portuguese\n"
16+
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
17+
"MIME-Version: 1.0\n"
18+
"Content-Type: text/plain; charset=utf-8\n"
19+
"Content-Transfer-Encoding: 8bit\n"
20+
"Generated-By: Babel 2.15.0\n"
21+
22+
#: python_docs_theme/footerdonate.html:1
23+
msgid "The Python Software Foundation is a non-profit corporation."
24+
msgstr "A Python Software Foundation é uma corporação sem fins lucrativos."
25+
26+
#: python_docs_theme/footerdonate.html:2
27+
msgid "Please donate."
28+
msgstr "Por favor, doe."
29+
30+
#: python_docs_theme/layout.html:6
31+
msgid "Navigation"
32+
msgstr "Navegação"
33+
34+
#: python_docs_theme/layout.html:51 python_docs_theme/layout.html:111
35+
msgid "Quick search"
36+
msgstr "Pesquisa rápida"
37+
38+
#: python_docs_theme/layout.html:52 python_docs_theme/layout.html:112
39+
msgid "Go"
40+
msgstr "Ir"
41+
42+
#: python_docs_theme/layout.html:60
43+
msgid "Theme"
44+
msgstr "Tema"
45+
46+
#: python_docs_theme/layout.html:62
47+
msgid "Auto"
48+
msgstr "Auto"
49+
50+
#: python_docs_theme/layout.html:63
51+
msgid "Light"
52+
msgstr "Claro"
53+
54+
#: python_docs_theme/layout.html:64
55+
msgid "Dark"
56+
msgstr "Escuro"
57+
58+
#: python_docs_theme/layout.html:96
59+
msgid "Menu"
60+
msgstr "Menu"
61+
62+
#: python_docs_theme/layout.html:142
63+
msgid "Copyright"
64+
msgstr "Copyright"
65+
66+
#: python_docs_theme/layout.html:147
67+
msgid ""
68+
"This page is licensed under the Python Software Foundation License "
69+
"Version 2."
70+
msgstr ""
71+
"Esta página está licenciada sob a licença Python Software Foundation "
72+
"Versão 2."
73+
74+
#: python_docs_theme/layout.html:149
75+
msgid ""
76+
"Examples, recipes, and other code in the documentation are additionally "
77+
"licensed under the Zero Clause BSD License."
78+
msgstr ""
79+
"Exemplos, receitas e outros códigos na documentação são adicionalmente "
80+
"licenciados soba licença Zero Clause BSD."
81+
82+
#: python_docs_theme/layout.html:152
83+
#, python-format
84+
msgid ""
85+
"See <a href=\"%(license_file)s\">History and License</a> for more "
86+
"information."
87+
msgstr ""
88+
"Veja <a href=\"%(license_file)s\">História e licença</a> para mais "
89+
"informações."
90+
91+
#: python_docs_theme/layout.html:155
92+
#, python-format
93+
msgid "Hosted on %(hosted_on)s."
94+
msgstr "Hospedado por %(hosted_on)s."
95+
96+
#: python_docs_theme/layout.html:163
97+
#, python-format
98+
msgid "Last updated on %(last_updated)s."
99+
msgstr "Última atualizãaço em %(last_updated)s."
100+
101+
#: python_docs_theme/layout.html:166
102+
#, python-format
103+
msgid "<a href=\"%(theme_issues_url)s\">Found a bug</a>?"
104+
msgstr "<a href=\"%(theme_issues_url)s\">Encontrou um bug</a>?"
105+
106+
#: python_docs_theme/layout.html:170
107+
#, python-format
108+
msgid ""
109+
"Created using <a href=\"https://www.sphinx-doc.org/\">Sphinx</a> "
110+
"%(sphinx_version)s."
111+
msgstr ""
112+
"Criado usando <a href=\"https://www.sphinx-doc.org/\">Sphinx</a> "
113+
"%(sphinx_version)s."

0 commit comments

Comments
 (0)