Work on a GitHub action to auto-update translations on Transifex

This commit is contained in:
Kovid Goyal 2020-07-31 22:02:13 +05:30
parent fe9653fa13
commit 5afeace988
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 49 additions and 2 deletions

34
.github/workflows/translations.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Transifex
on:
push:
branches: [master, ]
jobs:
Push-To-Transifex:
name: Update translations on Transifex
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@master
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@master
with:
python-version: 3.8
- name: Install calibre dependencies
run:
python setup/unix-ci.py install
- name: Install transifex client
run:
python -m pip install transifex-client
- name: Update translations
env:
tx: ${{ secrets.tx }}
run:
python setup/unix-ci.py pot

View File

@ -115,11 +115,24 @@ def main():
install_env() install_env()
run_python('setup.py bootstrap --ephemeral') run_python('setup.py bootstrap --ephemeral')
elif action == 'pot':
install_env()
transifexrc = '''\
[https://www.transifex.com]
api_hostname = https://api.transifex.com
hostname = https://www.transifex.com
password = PASSWORD
username = api
'''.replace('PASSWORD', os.environ['tx'])
with open(os.path.expanduser('~/.transifexrc'), 'w') as f:
f.write(transifexrc)
run_python('setup.py pot')
elif action == 'test': elif action == 'test':
os.environ['CI'] = 'true' os.environ['CI'] = 'true'
if ismacos: if ismacos:
os.environ['SSL_CERT_FILE' os.environ['SSL_CERT_FILE'] = os.path.abspath(
] = os.path.abspath('resources/mozilla-ca-certs.pem') 'resources/mozilla-ca-certs.pem')
install_env() install_env()
run_python('setup.py test') run_python('setup.py test')