Skip to content

Commit a3f8f17

Browse files
Some changes
Unable to test locally as I have limited internet
1 parent da07650 commit a3f8f17

File tree

4 files changed

+11
-37
lines changed

4 files changed

+11
-37
lines changed

build_status.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""
2-
Fetch build status of languages in the https://docs.python.org.
2+
Fetch translated names of languages.
33
4-
Yield a tuple of language code and a Boolean indicating
5-
whether it is in the language switcher.
4+
Yield a tuple of language code and a string with the translated name.
65
"""
76

87
import tomllib
@@ -11,28 +10,13 @@
1110
from urllib3 import PoolManager
1211

1312

14-
def get_languages(http: PoolManager) -> Iterator[tuple[str, str, bool]]:
13+
def get_languages(http: PoolManager) -> Iterator[tuple[str, str]]:
1514
data = http.request(
1615
'GET',
1716
'https://raw.githubusercontent.com/python/docsbuild-scripts/refs/heads/main/config.toml',
1817
).data
1918
config = tomllib.loads(data.decode())
2019
for code, language in config['languages'].items():
2120
language_code = code.lower().replace('_', '-')
22-
in_switcher = language.get('in_prod', config['defaults']['in_prod'])
2321
translated_name = language.get('translated_name')
24-
yield language_code, translated_name, in_switcher
25-
26-
27-
def main() -> None:
28-
languages = {
29-
language: in_switcher
30-
for language, translated_name, in_switcher in get_languages(PoolManager())
31-
}
32-
print(languages)
33-
for code in ('en', 'pl', 'ar', 'zh-cn', 'id'):
34-
print(f'{code}: {code in languages} {languages.get(code)}')
35-
36-
37-
if __name__ == '__main__':
38-
main()
22+
yield language_code, translated_name

generate.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from collections.abc import Iterator
77
from dataclasses import dataclass, asdict
88
from datetime import datetime, timezone
9-
from typing import Any, Dict
109
from pathlib import Path
1110

1211
from git import Repo
@@ -39,11 +38,9 @@ def get_completion_progress() -> Iterator['LanguageProjectData']:
3938
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True)
4039
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True)
4140

42-
languages_built: Dict[str, Dict[str, Any]] = {
43-
code: {'in_switcher': in_switcher, 'translated_name': translated_name}
44-
for code, translated_name, in_switcher in build_status.get_languages(
45-
PoolManager()
46-
)
41+
languages_built: dict[str, str] = {
42+
language: translated_name
43+
for language, translated_name in build_status.get_languages(PoolManager())
4744
}
4845

4946
with concurrent.futures.ThreadPoolExecutor() as executor:
@@ -58,7 +55,7 @@ def get_completion_progress() -> Iterator['LanguageProjectData']:
5855
def get_project_data(
5956
language: Language,
6057
repo: str | None,
61-
languages_built: Dict[str, Dict[str, Any]],
58+
languages_built: dict[str, str],
6259
clones_dir: str,
6360
) -> 'LanguageProjectData':
6461
built = language.code in languages_built
@@ -70,10 +67,6 @@ def get_project_data(
7067
change = 0.0
7168
branch = ''
7269

73-
language_data = languages_built.get(language.code, {})
74-
translated_name = language_data.get('translated_name', '')
75-
in_switcher = language_data.get('in_switcher', False)
76-
7770
return LanguageProjectData(
7871
language,
7972
repo,
@@ -82,8 +75,7 @@ def get_project_data(
8275
change,
8376
translators_data,
8477
built,
85-
translated_name=translated_name,
86-
in_switcher=in_switcher,
78+
translated_name=languages_built.get(language.code, ''),
8779
uses_platform=language.code in contribute.pulling_from_transifex,
8880
contribution_link=contribute.get_contrib_link(language.code, repo),
8981
)
@@ -99,7 +91,6 @@ class LanguageProjectData:
9991
translators: TranslatorsData
10092
built: bool
10193
translated_name: str
102-
in_switcher: bool | None
10394
uses_platform: bool
10495
contribution_link: str | None
10596

@@ -117,7 +108,6 @@ class LanguageProjectData:
117108
completion_progress=completion_progress,
118109
generation_time=generation_time,
119110
duration=(datetime.now(timezone.utc) - generation_time).seconds,
120-
counts=counts,
121111
)
122112

123113
Path('build/style.css').write_bytes(Path('src/style.css').read_bytes())

src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ a:hover {
5151

5252
.card {
5353
flex: 1;
54+
transition: all 0.3s ease-in-out;
5455
}
5556

5657
.card:hover {
5758
text-decoration: none;
5859
transform: scale(1.05);
59-
transition: all 0.3s ease-in-out;
6060
}
6161

6262
@media (min-width: 768px) {

templates/index.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</div>
4747

4848
<p style="text-align: center;">
49-
Last updated on {{ generation_time.strftime('%A, %-d %B %Y, %-H:%M:%S %Z') }} (in {{ duration // 60 }}:{{ "{:02}".format(duration % 60) }} minutes).<br/>
49+
Last updated {{ generation_time.strftime('on %A %-d %B %Y at %-H:%M:%S %Z') }} (in {{ duration // 60 }} minutes and {{ duration % 60 }} seconds).<br/>
5050
You can find the scripts used to generate this website <a href="https://github.com/python-docs-translations/dashboard/">on GitHub</a>.<br/>
5151
You can download the data on this page in <a href="https://github.com/python-docs-translations/dashboard/blob/gh-pages/index.json">JSON format</a>.
5252
</p>

0 commit comments

Comments
 (0)