Skip to content

Sync Translations #1660

Sync Translations

Sync Translations #1660

name: Sync Translations
on:
workflow_dispatch:
push:
branches: [master]
schedule:
# * is a special character in YAML so you have to quote this string
# run every day at 00:42
- cron: '42 0 * * *'
permissions: {}
jobs:
sync-translations:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Install Dependencies
run: |
sudo apt-get -qq update
sudo apt-get -qq install gettext qt6-l10n-tools
- name: Checkout current repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Checkout avogadroapp
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: openchemistry/avogadroapp
path: openchemistry/avogadroapp
persist-credentials: false
- name: Checkout avogadrolibs
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: openchemistry/avogadrolibs
path: openchemistry/avogadrolibs
persist-credentials: false
- name: Debug file layout
run: |
echo `pwd`
echo `ls -d *`
- name: Update avogadrolibs QM files
run: |
PROJECT=avogadrolibs
cd openchemistry/${PROJECT}/i18n
# generate the TS files from the PO files
echo "Generating TS"
for file in *.po; do
/usr/lib/qt6/bin/lconvert $file -o ${file%.po}.ts
done
echo "updating TS"
for file in *.ts; do
/usr/lib/qt6/bin/lupdate .. -ts $file
done
# generate the QM files from TS files
echo "Generating QM"
/usr/lib/qt6/bin/lrelease -compress -removeidentical *.ts
# don't keep the TS anymore
rm *.ts
echo "Renaming QM"
for file in *.qm; do
mv ${file} ${PROJECT}-${file}
done
echo `ls *.qm`
mv *.qm ${GITHUB_WORKSPACE}/${PROJECT}
- name: Update avogadroapp QM files
run: |
PROJECT=avogadroapp
cd openchemistry/${PROJECT}/i18n
# generate the TS files from the PO files
for file in *.po; do
/usr/lib/qt6/bin/lconvert $file -o ${file%.po}.ts
done
echo "updating TS"
for file in *.ts; do
/usr/lib/qt6/bin/lupdate .. -ts $file
done
# generate the QM files from TS files
/usr/lib/qt6/bin/lrelease -compress -removeidentical *.ts
# don't keep the TS anymore
rm *.ts
for file in *.qm; do
mv ${file} ${PROJECT}-${file}
done
mv *.qm ${GITHUB_WORKSPACE}/${PROJECT}
- name: Update git repo
if: github.event_name != 'pull_request'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
git add '*/*.qm'
git diff --staged --quiet || git commit -m "Apply automatic translations"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: ${{ runner.workspace }}/*/*.qm
name: AvoI18n