Skip to content

Commit 7cda00d

Browse files
committed
New CI
1 parent 6a595f0 commit 7cda00d

File tree

3 files changed

+480
-486
lines changed

3 files changed

+480
-486
lines changed

.github/scripts/manage_translation.py

+1-31
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,6 @@ def _slug_to_file_path(slug: str) -> Path:
3535
return Path(file_path)
3636

3737

38-
def recreate_config() -> None:
39-
"""Regenerate Transifex client config for all resources."""
40-
resources = transifex_api.Resource.filter(project=PROJECT).all()
41-
with open('.tx/config', 'w') as fo:
42-
fo.writelines(('[main]\n', 'host = https://api.transifex.com\n',))
43-
for resource in resources:
44-
path = _slug_to_file_path(resource.slug)
45-
fo.writelines((
46-
'\n',
47-
f'[{resource.id}]\n',
48-
f'file_filter = {path}\n',
49-
'type = PO\n',
50-
'source_lang = en\n',
51-
'minimum_perc = 0\n',
52-
f'trans.{LANG} = {path}\n',
53-
f'source_file = {path}\n',
54-
f'resource_name = {resource.name}\n'
55-
))
56-
57-
5838
def recreate_resource_stats() -> None:
5939
"""Create resource stats."""
6040
stats = transifex_api.ResourceLanguageStats.filter(project=PROJECT, language=LANGUAGE).all()
@@ -94,18 +74,8 @@ def recreate_team_stats() -> None:
9474
fo.writelines(f"| {user} | {role} | {translators[user]} | {reviewers[user]} | {proofreaders[user]} |\n")
9575

9676

97-
def fetch_translations():
98-
"""Fetch translations from Transifex, remove source lines."""
99-
return_code = os.system(f'./tx pull -l {LANG} --force --skip')
100-
exit(return_code)
101-
102-
def format_translations():
103-
"""Format translations using 'msgcat' from 'gettext'"""
104-
return_code = os.system('find -name "*.po" -exec msgcat --no-location -o {} {} \;')
105-
exit(return_code)
106-
10777
if __name__ == "__main__":
108-
RUNNABLE_SCRIPTS = ('recreate_config', 'recreate_resource_stats', 'recreate_team_stats', 'fetch_translations', 'format_translations')
78+
RUNNABLE_SCRIPTS = ('recreate_resource_stats', 'recreate_team_stats')
10979

11080
parser = ArgumentParser()
11181
parser.add_argument('cmd', nargs=1, choices=RUNNABLE_SCRIPTS)

.github/workflows/update-and-build.yml

+26-9
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,45 @@ jobs:
2323
- uses: actions/setup-python@master
2424
with:
2525
python-version: 3
26-
- run: sudo apt-get install -y gettext
27-
- run: pip install transifex-python six
26+
- run: sudo apt-get install -y gettext rsync
27+
- run: pip install transifex-python six sphinx-intl blurb
2828
- run: curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
2929
working-directory: /usr/local/bin
3030
- uses: actions/checkout@master
3131
with:
32-
ref: ${{ matrix.version }}
33-
- run: .github/scripts/manage_translation.py recreate_config
32+
repository: python/cpython
33+
ref: main
34+
path: cpython
35+
- run: make gettext
36+
working-directory: cpython/Doc
37+
- run: sphinx-intl create-txconfig
38+
working-directory: cpython/Doc/build
39+
- run: sphinx-intl update-txconfig-resources --transifex-organization-name python-doc --transifex-project-name python-newest -d . -p gettext
40+
working-directory: cpython/Doc/build
3441
env:
3542
TX_TOKEN: ${{ secrets.TX_TOKEN }}
36-
- run: .github/scripts/manage_translation.py fetch_translations
43+
- run: tx pull -l uk --force --skip
44+
working-directory: cpython/Doc/build
3745
env:
3846
TX_TOKEN: ${{ secrets.TX_TOKEN }}
3947
- run: find -name "*.po" -exec msgcat --no-location -o {} {} \;
40-
- run: git config --local user.email github-actions@github.com
41-
- run: git config --local user.name "GitHub Action's update-translation job"
42-
- run: git add .
43-
- run: git commit -m 'Update translation from Transifex' || true
48+
working-directory: cpython/Doc/build
49+
- uses: actions/checkout@master
50+
with:
51+
ref: ${{ matrix.version }}
52+
path: python-docs-uk
53+
- run: rsync -r --del --exclude .git --exclude Makefile cpython/Doc/build/uk/LC_MESSAGES/ python-docs-uk
54+
- run: |
55+
git config --local user.email github-actions@github.com
56+
git config --local user.name "GitHub Action's update-translation job"
57+
git add .
58+
git commit -m 'Update translation from Transifex' || true
59+
working-directory: python-docs-uk
4460
- uses: ad-m/github-push-action@master
4561
with:
4662
branch: ${{ matrix.version }}
4763
github_token: ${{ secrets.GITHUB_TOKEN }}
64+
directory: python-docs-uk
4865

4966
lint-translation:
5067
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)