2323from __future__ import annotations
2424
2525from argparse import ArgumentParser , Namespace
26- from collections .abc import Sequence
26+ from collections .abc import Iterable , Sequence
2727from contextlib import suppress , contextmanager
2828from dataclasses import dataclass
2929import filecmp
4242from pathlib import Path
4343from string import Template
4444from time import perf_counter , sleep
45- from typing import Iterable , Literal
45+ from typing import Literal
4646from urllib .parse import urljoin
4747
4848import jinja2
@@ -196,6 +196,7 @@ def __gt__(self, other):
196196class 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 ),
0 commit comments