Update messages #1308
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update messages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - 'Letos/**/*.cpp' | |
| - 'Letos/**/*.h' | |
| - 'Letos/**/*.hpp' | |
| - 'Letos/**/*.ui' | |
| - 'Letos/**/*.qrc' | |
| - 'Plugins/**/*.cpp' | |
| - 'Plugins/**/*.h' | |
| - 'Plugins/**/*.hpp' | |
| - 'Plugins/**/*.ui' | |
| - 'Plugins/**/*.qrc' | |
| - '.github/workflows/update_messages.yml' | |
| schedule: | |
| - cron: '30 5 * * *' # run at 5:30 AM UTC every day | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install Qt tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y qt6-l10n-tools | |
| echo "/usr/lib/qt6/bin" >> $GITHUB_PATH | |
| - name: Clone repo | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ env.GITHUB_REF }} | |
| - name: Update translations | |
| run: | | |
| set -euo pipefail | |
| echo "Using lupdate: $(which lupdate) ($(lupdate -version))" | |
| dirs=() | |
| for p in core gui letos | |
| do | |
| dirs+=("Letos/$p") | |
| done | |
| for d in Plugins/* | |
| do | |
| [ -d "$d" ] || continue | |
| dirs+=("$d") | |
| done | |
| for d in "${dirs[@]}" | |
| do | |
| if [[ "$d" == Plugins/* ]] && [ ! -d "$d/translations" ] | |
| then | |
| mkdir -p "$d/translations" | |
| fi | |
| [ -d "$d/translations" ] || continue | |
| source_ts_files=() | |
| while IFS= read -r f | |
| do | |
| source_ts_files+=("$f") | |
| done < <(find "$d/translations" -maxdepth 1 -name "*.ts" ! -name "*_*.ts" | sort) | |
| if [[ "$d" == Plugins/* ]] && [ ${#source_ts_files[@]} -eq 0 ] | |
| then | |
| plugin_name="$(basename "$d")" | |
| source_ts_files+=("$d/translations/${plugin_name}.ts") | |
| fi | |
| for f in "${source_ts_files[@]}" | |
| do | |
| lupdate "$d" -ts "$f" | |
| lconvert -sort-contexts -o "$f.tmp" "$f" | |
| mv "$f.tmp" "$f" | |
| done | |
| done | |
| - name: Listing Git status | |
| run: | | |
| git status | |
| echo "===========================================================================" | |
| git diff | |
| - name: Committing changes | |
| run: | | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git add . | |
| git diff-index --quiet HEAD || git commit -m "Automated update of translation files." | |
| git push |