CI: Automatically synchronize translations with CrowdIn
This commit is contained in:
64
.github/workflows/fetch_crowdin_translations.yml
vendored
Normal file
64
.github/workflows/fetch_crowdin_translations.yml
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
name: Fetch Crowdin Translations
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 0 * * 1"
|
||||
|
||||
jobs:
|
||||
update-crowdin:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Qt ≥ 6.8
|
||||
uses: jurplel/install-qt-action@v3
|
||||
with:
|
||||
aqtversion: "==3.1.*"
|
||||
version: "6.8.3"
|
||||
host: "linux"
|
||||
target: "desktop"
|
||||
arch: "linux_gcc_64"
|
||||
|
||||
- name: Setup Python & dependencies
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Install Python packages
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
pip install pyside6
|
||||
|
||||
- name: Gather translations from crowdin
|
||||
run: |
|
||||
./updatecrowdin.py build
|
||||
while ./updatecrowdin.py build-status | grep -q "status: inProgress"; do sleep 10; done
|
||||
./updatecrowdin.py download
|
||||
./updatecrowdin.py install
|
||||
working-directory: ./src/Tools
|
||||
env:
|
||||
CROWDIN_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
|
||||
CROWDIN_PROJECT_ID: freecad
|
||||
|
||||
- name: Commit changes
|
||||
run: |
|
||||
git config --global user.name "github-actions"
|
||||
git config --global user.email "github-actions@github.com"
|
||||
git add -A
|
||||
git commit -m "Update translations from Crowdin" || echo "No changes to commit"
|
||||
|
||||
- name: Push changes to a new branch
|
||||
run: |
|
||||
git branch update-crowdin-translations
|
||||
git push origin update-crowdin-translations --force
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
branch: update-crowdin-translations
|
||||
title: "Update translations from Crowdin"
|
||||
body: "Automatic Crowdin update."
|
||||
labels: "translations, automated"
|
||||
42
.github/workflows/push_crowdin_translations.yml
vendored
Normal file
42
.github/workflows/push_crowdin_translations.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
name: Push Crowdin Translations
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 0 * * 1"
|
||||
|
||||
jobs:
|
||||
update-crowdin:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Qt ≥ 6.8
|
||||
uses: jurplel/install-qt-action@v3
|
||||
with:
|
||||
aqtversion: "==3.1.*"
|
||||
version: "6.8.3"
|
||||
host: "linux"
|
||||
target: "desktop"
|
||||
arch: "linux_gcc_64"
|
||||
|
||||
- name: Setup Python & dependencies
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Install Python packages
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
pip install pyside6
|
||||
|
||||
- name: Push translations to Crowdin
|
||||
run: |
|
||||
./updatecrowdin.py gather
|
||||
./updatecrowdin.py upload
|
||||
working-directory: ./src/Tools
|
||||
env:
|
||||
CROWDIN_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
|
||||
CROWDIN_PROJECT_ID: freecad
|
||||
@@ -325,12 +325,15 @@ class CrowdinUpdater:
|
||||
|
||||
|
||||
def load_token():
|
||||
# load API token stored in ~/.crowdin-freecad-token
|
||||
config_file = os.path.expanduser("~") + os.sep + ".crowdin-freecad-token"
|
||||
# try to read token from ~/.crowdin-freecad-token
|
||||
config_file = os.path.join(os.path.expanduser("~"), ".crowdin-freecad-token")
|
||||
if os.path.exists(config_file):
|
||||
with open(config_file) as file:
|
||||
return file.read().strip()
|
||||
return None
|
||||
with open(config_file, "r") as file:
|
||||
token = file.read().strip()
|
||||
if token:
|
||||
return token
|
||||
# if file does'nt exists read from CROWDIN_TOKEN
|
||||
return os.environ.get("CROWDIN_TOKEN")
|
||||
|
||||
|
||||
def updateqrc(qrcpath, lncode):
|
||||
@@ -522,9 +525,9 @@ if __name__ == "__main__":
|
||||
|
||||
project_identifier = os.environ.get("CROWDIN_PROJECT_ID")
|
||||
if not project_identifier:
|
||||
project_identifier = "freecad"
|
||||
# print('CROWDIN_PROJECT_ID env var must be set')
|
||||
# sys.exit()
|
||||
# project_identifier = "freecad"
|
||||
print("CROWDIN_PROJECT_ID env var must be set")
|
||||
sys.exit()
|
||||
|
||||
updater = CrowdinUpdater(token, project_identifier)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user