Skip to content

Commit e01effb

Browse files
chore: Add 3.12 to workflow
1 parent c3d4b1a commit e01effb

File tree

3 files changed

+48
-13
lines changed

3 files changed

+48
-13
lines changed

.github/scripts/generate_tx_config.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from functools import partial
55
from pathlib import Path
66
import re
7+
import os
78

89
run = partial(subprocess.run, check=True)
910

@@ -12,15 +13,15 @@ def init_project():
1213
run(["tx", "init"])
1314

1415

15-
def add_files(version: str):
16+
def add_files(project_name: str):
1617
run(
1718
[
1819
"tx",
1920
"add",
2021
"remote",
2122
"--file-filter",
2223
"trans/<lang>/<resource_slug>.<ext>",
23-
f"https://www.transifex.com/python-doc/{version}/dashboard/",
24+
f"https://www.transifex.com/python-doc/{project_name}/dashboard/",
2425
]
2526
)
2627

@@ -42,7 +43,7 @@ def name_replacer(match: re.Match[str]):
4243
matches = list(glob.glob(pattern.replace(".po", ".rst")))
4344
if not matches:
4445
print("missing", pattern)
45-
return f"{prefix}{resource}\n{override_prefix}{pattern}"
46+
return f"{prefix}{resource}\n{override_prefix}{pattern.replace('?', '_')}"
4647
elif len(matches) == 1:
4748
filename = matches[0].replace(".rst", ".po").replace("\\", "/")
4849
else:
@@ -65,18 +66,18 @@ def patch_config(path: str):
6566

6667
if __name__ == "__main__":
6768
from argparse import ArgumentParser
68-
import os
6969

7070
parser = ArgumentParser()
7171

72-
parser.add_argument("--token", required=True)
73-
parser.add_argument("--version", required=True)
72+
parser.add_argument("--token", default="")
73+
parser.add_argument("--project-name", required=True)
7474
parser.add_argument("--doc-path", required=True)
7575

7676
params = parser.parse_args()
7777

78-
os.environ["TX_TOKEN"] = params.token
78+
if params.token:
79+
os.environ["TX_TOKEN"] = params.token
7980

8081
init_project()
81-
add_files(params.version)
82+
add_files(params.project_name)
8283
patch_config(params.doc_path)

.github/workflows/python-312.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: python-312
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
schedule:
8+
- cron: "42 * * * *"
9+
10+
jobs:
11+
sync:
12+
runs-on: ubuntu-latest
13+
env:
14+
LOCALE: zh_CN
15+
VERSION: "3.12"
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: prepare
19+
run: .github/scripts/prepare.sh
20+
- name: update
21+
run: .github/scripts/update.sh
22+
env:
23+
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
24+
- name: build
25+
run: .github/scripts/build.sh
26+
- name: commit
27+
run: .github/scripts/commit.sh
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.rst

+10-5
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,36 @@ Maintained versions:
1212
* - Version
1313
- Sync status
1414
- Translation progress
15+
* - `3.12 <https://github.com/python/python-docs-zh-cn/tree/3.12>`_
16+
- .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-312/badge.svg
17+
:target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-312
18+
- .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/312
19+
:target: https://app.transifex.com/python-doc/python-newest/
1520
* - `3.11 <https://github.com/python/python-docs-zh-cn/tree/3.11>`_
1621
- .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-311/badge.svg
1722
:target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-311
1823
- .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/311
19-
:target: https://www.transifex.com/python-doc/python-311/
24+
:target: https://app.transifex.com/python-doc/python-311/
2025
* - `3.10 <https://github.com/python/python-docs-zh-cn/tree/3.10>`_
2126
- .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-310/badge.svg
2227
:target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-310
2328
- .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/310
24-
:target: https://www.transifex.com/python-doc/python-310/
29+
:target: https://app.transifex.com/python-doc/python-310/
2530
* - `3.9 <https://github.com/python/python-docs-zh-cn/tree/3.9>`_
2631
- .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-39/badge.svg
2732
:target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-39
2833
- .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/39
29-
:target: https://www.transifex.com/python-doc/python-39/
34+
:target: https://app.transifex.com/python-doc/python-39/
3035
* - `3.8 <https://github.com/python/python-docs-zh-cn/tree/3.8>`_
3136
- .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-38/badge.svg
3237
:target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-38
3338
- .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/38
34-
:target: https://www.transifex.com/python-doc/python-38/
39+
:target: https://app.transifex.com/python-doc/python-38/
3540
* - `3.7 <https://github.com/python/python-docs-zh-cn/tree/3.7>`_
3641
- .. image:: https://github.com/python/python-docs-zh-cn/workflows/python-37/badge.svg
3742
:target: https://github.com/python/python-docs-zh-cn/actions?workflow=python-37
3843
- .. image:: https://img.shields.io/badge/dynamic/json.svg?label=zh_CN&query=%24.zh_CN&url=http://gce.zhsj.me/python/37
39-
:target: https://www.transifex.com/python-doc/python-37/
44+
:target: https://app.transifex.com/python-doc/python-37/
4045

4146
Documentation Contribution Agreement
4247
------------------------------------

0 commit comments

Comments
 (0)