Skip to content

Commit 9fdb8da

Browse files
authored
Merge branch 'main' into add-gr-translation
2 parents b7d32e7 + 273cd3c commit 9fdb8da

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
python-version: ["3.10", "3.11", "3.12", "3.13"]
17+
python-version: ["3.13", "3.14"]
1818
os: [ubuntu-latest]
1919

2020
steps:

build_docs.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from __future__ import annotations
2424

2525
from argparse import ArgumentParser, Namespace
26-
from collections.abc import Sequence
26+
from collections.abc import Iterable, Sequence
2727
from contextlib import suppress, contextmanager
2828
from dataclasses import dataclass
2929
import filecmp
@@ -42,7 +42,7 @@
4242
from pathlib import Path
4343
from string import Template
4444
from time import perf_counter, sleep
45-
from typing import Iterable, Literal
45+
from typing import Literal
4646
from urllib.parse import urljoin
4747

4848
import jinja2
@@ -196,6 +196,7 @@ def __gt__(self, other):
196196
class Language:
197197
iso639_tag: str
198198
name: str
199+
translated_name: str
199200
in_prod: bool
200201
sphinxopts: tuple
201202
html_only: bool = False
@@ -214,6 +215,12 @@ def repo_url(self):
214215
)
215216
return f"https://github.com/python/{repo_name}.git"
216217

218+
@property
219+
def switcher_label(self):
220+
if self.translated_name:
221+
return f"{self.name} | {self.translated_name}"
222+
return self.name
223+
217224
@staticmethod
218225
def filter(languages, language_tags=None):
219226
"""Filter a sequence of languages according to --languages."""
@@ -398,7 +405,7 @@ def setup_switchers(
398405
- Cross-link various languages in a language switcher
399406
- Cross-link various versions in a version switcher
400407
"""
401-
language_pairs = sorted((l.tag, l.name) for l in languages if l.in_prod)
408+
language_pairs = sorted((l.tag, l.switcher_label) for l in languages if l.in_prod)
402409
version_pairs = [(v.name, v.picker_label) for v in reversed(versions)]
403410

404411
switchers_template_file = HERE / "templates" / "switchers.js"
@@ -482,15 +489,15 @@ def version_info():
482489
"""Handler for --version."""
483490
try:
484491
platex_version = head(
485-
subprocess.check_output(["platex", "--version"], universal_newlines=True),
492+
subprocess.check_output(["platex", "--version"], text=True),
486493
lines=3,
487494
)
488495
except FileNotFoundError:
489496
platex_version = "Not installed."
490497

491498
try:
492499
xelatex_version = head(
493-
subprocess.check_output(["xelatex", "--version"], universal_newlines=True),
500+
subprocess.check_output(["xelatex", "--version"], text=True),
494501
lines=2,
495502
)
496503
except FileNotFoundError:
@@ -719,7 +726,7 @@ def build(self):
719726
f"-D locale_dirs={locale_dirs}",
720727
f"-D language={self.language.iso639_tag}",
721728
"-D gettext_compact=0",
722-
# "-D translation_progress_classes=1",
729+
"-D translation_progress_classes=1",
723730
)
724731
)
725732
if self.language.tag == "ja":
@@ -1160,13 +1167,15 @@ def parse_languages_from_config() -> list[Language]:
11601167
"""Read config.toml to discover languages to build."""
11611168
config = tomlkit.parse((HERE / "config.toml").read_text(encoding="UTF-8"))
11621169
defaults = config["defaults"]
1170+
default_translated_name = defaults.get("translated_name", "")
11631171
default_in_prod = defaults.get("in_prod", True)
11641172
default_sphinxopts = defaults.get("sphinxopts", [])
11651173
default_html_only = defaults.get("html_only", False)
11661174
return [
11671175
Language(
11681176
iso639_tag=iso639_tag,
11691177
name=section["name"],
1178+
translated_name=section.get("translated_name", default_translated_name),
11701179
in_prod=section.get("in_prod", default_in_prod),
11711180
sphinxopts=section.get("sphinxopts", default_sphinxopts),
11721181
html_only=section.get("html_only", default_html_only),

config.toml

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
# name: the English name for the language.
2+
# translated_name: the 'local' name for the language.
3+
# in_prod: If true, include in the language switcher.
4+
# html_only: If true, only create HTML files.
5+
# sphinxopts: Extra options to pass to SPHINXOPTS in the Makefile.
6+
17
[defaults]
28
# name has no default, it is mandatory.
9+
translated_name = ""
310
in_prod = true
411
html_only = false
512
sphinxopts = [
@@ -13,6 +20,7 @@ name = "English"
1320

1421
[languages.es]
1522
name = "Spanish"
23+
translated_name = "español"
1624
sphinxopts = [
1725
'-D latex_engine=xelatex',
1826
'-D latex_elements.inputenc=',
@@ -21,6 +29,7 @@ sphinxopts = [
2129

2230
[languages.fr]
2331
name = "French"
32+
translated_name = "français"
2433
sphinxopts = [
2534
'-D latex_engine=xelatex',
2635
'-D latex_elements.inputenc=',
@@ -29,13 +38,16 @@ sphinxopts = [
2938

3039
[languages.id]
3140
name = "Indonesian"
41+
translated_name = "Indonesia"
3242
in_prod = false
3343

3444
[languages.it]
3545
name = "Italian"
46+
translated_name = "italiano"
3647

3748
[languages.ja]
3849
name = "Japanese"
50+
translated_name = "日本語"
3951
sphinxopts = [
4052
'-D latex_engine=lualatex',
4153
'-D latex_elements.inputenc=',
@@ -59,6 +71,7 @@ sphinxopts = [
5971

6072
[languages.ko]
6173
name = "Korean"
74+
translated_name = "한국어"
6275
sphinxopts = [
6376
'-D latex_engine=xelatex',
6477
'-D latex_elements.inputenc=',
@@ -68,20 +81,25 @@ sphinxopts = [
6881

6982
[languages.pl]
7083
name = "Polish"
84+
translated_name = "polski"
7185

7286
[languages.pt_BR]
7387
name = "Brazilian Portuguese"
88+
translated_name = "Português brasileiro"
7489

7590
[languages.tr]
7691
name = "Turkish"
92+
translated_name = "Türkçe"
7793

7894
[languages.uk]
7995
name = "Ukrainian"
96+
translated_name = "українська"
8097
in_prod = false
8198
html_only = true
8299

83100
[languages.zh_CN]
84101
name = "Simplified Chinese"
102+
translated_name = "简体中文"
85103
sphinxopts = [
86104
'-D latex_engine=xelatex',
87105
'-D latex_elements.inputenc=',
@@ -90,6 +108,7 @@ sphinxopts = [
90108

91109
[languages.zh_TW]
92110
name = "Traditional Chinese"
111+
translated_name = "繁體中文"
93112
sphinxopts = [
94113
'-D latex_engine=xelatex',
95114
'-D latex_elements.inputenc=',

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires =
33
tox>=4.2
44
env_list =
55
lint
6-
py{313, 312, 311, 310}
6+
py{314, 313}
77

88
[testenv]
99
package = wheel

0 commit comments

Comments
 (0)