|
| 1 | +name: Update Translations |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # Manual trigger |
| 5 | + schedule: |
| 6 | + - cron: '0 0 * * 0' # Weekly on Sunday at midnight |
| 7 | + pull_request: # Run on every PR commit for testing |
| 8 | + paths: |
| 9 | + - 'src/**/*.cpp' |
| 10 | + - 'src/**/*.h' |
| 11 | + - 'src/**/*.qml' |
| 12 | + - 'src/**/*.ui' |
| 13 | + - 'src/**/*.ts' |
| 14 | + push: # Run on push to PR branches |
| 15 | + branches: |
| 16 | + - 'claude/**' # All Claude Code branches |
| 17 | + - 'translations/**' # Translation-specific branches |
| 18 | + |
| 19 | +jobs: |
| 20 | + update-translations: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + |
| 30 | + - name: Install Qt Linguist Tools |
| 31 | + run: | |
| 32 | + sudo apt-get update |
| 33 | + sudo apt-get install -y qtbase5-dev qttools5-dev-tools |
| 34 | +
|
| 35 | + - name: Detect workflow context |
| 36 | + id: context |
| 37 | + run: | |
| 38 | + if [ "${{ github.event_name }}" = "pull_request" ] || [ "${{ github.event_name }}" = "push" ]; then |
| 39 | + echo "mode=testing" >> $GITHUB_OUTPUT |
| 40 | + echo "🧪 Running in TESTING mode (PR/push to branch)" |
| 41 | + else |
| 42 | + echo "mode=production" >> $GITHUB_OUTPUT |
| 43 | + echo "🚀 Running in PRODUCTION mode (scheduled/manual)" |
| 44 | + fi |
| 45 | +
|
| 46 | + - name: Update translation files |
| 47 | + run: | |
| 48 | + echo "Extracting translatable strings from source code..." |
| 49 | + echo "Updating 30 language files..." |
| 50 | +
|
| 51 | + # lupdate will create/update all .ts files defined in TRANSLATIONS |
| 52 | + lupdate src/qdomyos-zwift.pri |
| 53 | +
|
| 54 | + - name: Compile translation binaries (.qm) |
| 55 | + run: | |
| 56 | + echo "Compiling .ts files into .qm binaries..." |
| 57 | + lrelease src/qdomyos-zwift.pri |
| 58 | +
|
| 59 | + - name: Verify generated .qm files |
| 60 | + run: | |
| 61 | + echo "Checking compiled translation files..." |
| 62 | + ls -1 src/translations/*.qm |
| 63 | +
|
| 64 | + - name: Check for translation changes |
| 65 | + run: | |
| 66 | + echo "" |
| 67 | + echo "Checking for changes..." |
| 68 | +
|
| 69 | + # Check if there are changes in translations folder |
| 70 | + if git diff --quiet src/translations/; then |
| 71 | + echo "✅ No translation updates needed - files are up to date" |
| 72 | + echo "HAS_CHANGES=false" >> $GITHUB_ENV |
| 73 | + else |
| 74 | + echo "📝 Translation files have been updated with new/modified strings" |
| 75 | + echo "HAS_CHANGES=true" >> $GITHUB_ENV |
| 76 | +
|
| 77 | + # Show diff stats |
| 78 | + echo "" |
| 79 | + echo "Changes summary:" |
| 80 | + git diff --stat src/translations/ |
| 81 | +
|
| 82 | + echo "" |
| 83 | + echo "Files modified:" |
| 84 | + git diff --name-only src/translations/ |
| 85 | + fi |
| 86 | +
|
| 87 | + - name: Commit and push changes (Testing Mode) |
| 88 | + if: env.HAS_CHANGES == 'true' && steps.context.outputs.mode == 'testing' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) |
| 89 | + env: |
| 90 | + TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} |
| 91 | + run: | |
| 92 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 93 | + git config --local user.name "github-actions[bot]" |
| 94 | +
|
| 95 | + # Commit updated translation source files only |
| 96 | + git add src/translations/*.ts |
| 97 | + git commit -m "chore: update translation strings [automated] |
| 98 | +
|
| 99 | + Automatic update of translatable strings extracted from source code. |
| 100 | + Updated 30 language files in src/translations/ |
| 101 | +
|
| 102 | + - Updated by GitHub Actions (Testing Mode) |
| 103 | + - Triggered by: ${{ github.event_name }} |
| 104 | + - Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" |
| 105 | +
|
| 106 | + # Push to remote branch explicitly (works also in detached HEAD on pull_request events) |
| 107 | + git push origin HEAD:refs/heads/${TARGET_BRANCH} |
| 108 | +
|
| 109 | + echo "✅ Changes committed and pushed to current branch" |
| 110 | +
|
| 111 | + - name: Commit and push changes (Production Mode) |
| 112 | + if: env.HAS_CHANGES == 'true' && steps.context.outputs.mode == 'production' |
| 113 | + run: | |
| 114 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 115 | + git config --local user.name "github-actions[bot]" |
| 116 | +
|
| 117 | + # Create a new branch for production updates |
| 118 | + BRANCH_NAME="translations/auto-update-$(date +%Y%m%d-%H%M%S)" |
| 119 | + git checkout -b "$BRANCH_NAME" |
| 120 | +
|
| 121 | + # Add updated translation source files only |
| 122 | + git add src/translations/*.ts |
| 123 | + git commit -m "chore: update translation strings |
| 124 | +
|
| 125 | + Automatic update of translatable strings extracted from source code. |
| 126 | + Updated 30 language files in src/translations/ |
| 127 | +
|
| 128 | + - Updated by GitHub Actions (Scheduled) |
| 129 | + - Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" |
| 130 | +
|
| 131 | + # Push the branch |
| 132 | + git push origin "$BRANCH_NAME" |
| 133 | +
|
| 134 | + # Store branch name for PR creation |
| 135 | + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV |
| 136 | + echo "✅ Changes pushed to new branch: $BRANCH_NAME" |
| 137 | +
|
| 138 | + - name: Create Pull Request (Production Mode Only) |
| 139 | + if: env.HAS_CHANGES == 'true' && steps.context.outputs.mode == 'production' |
| 140 | + uses: peter-evans/create-pull-request@v5 |
| 141 | + with: |
| 142 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 143 | + branch: ${{ env.BRANCH_NAME }} |
| 144 | + title: "🌍 Update translation strings" |
| 145 | + body: | |
| 146 | + ## Translation Update |
| 147 | +
|
| 148 | + This PR updates the translation file with new strings extracted from the source code. |
| 149 | +
|
| 150 | + ### Changes |
| 151 | + - Extracted new translatable strings using `lupdate` |
| 152 | + - Updated 30 language files in `src/translations/` |
| 153 | + - Languages: Italian, German, French, Spanish, Portuguese, Russian, Chinese, Japanese, Korean, Arabic, Hindi, and 19 more |
| 154 | +
|
| 155 | + ### What to do next |
| 156 | + 1. Review the new strings in `src/translations/qdomyos-zwift_*.ts` |
| 157 | + 2. Contributors can now create PRs to add translations in their language |
| 158 | + 3. Edit the `.ts` file for your language and add translations in `<translation>` tags |
| 159 | + 4. Merge this PR to make new strings available |
| 160 | +
|
| 161 | + ### Translation Files |
| 162 | + - Location: `src/translations/` |
| 163 | + - Format: `qdomyos-zwift_LOCALE.ts` (e.g., `qdomyos-zwift_it.ts` for Italian) |
| 164 | + - 30 languages supported |
| 165 | +
|
| 166 | + **Note:** Strings marked as `<translation type="unfinished">` need translation. |
| 167 | +
|
| 168 | + --- |
| 169 | + *Generated automatically by GitHub Actions* |
| 170 | + labels: | |
| 171 | + translations |
| 172 | + automation |
| 173 | +
|
| 174 | + - name: Summary |
| 175 | + if: always() |
| 176 | + run: | |
| 177 | + echo "" |
| 178 | + echo "============================================" |
| 179 | + echo "Translation Workflow Summary" |
| 180 | + echo "============================================" |
| 181 | + echo "Mode: ${{ steps.context.outputs.mode }}" |
| 182 | + echo "Event: ${{ github.event_name }}" |
| 183 | + echo "Has changes: ${{ env.HAS_CHANGES }}" |
| 184 | + echo "============================================" |
| 185 | +
|
| 186 | + if [ "${{ env.HAS_CHANGES }}" = "true" ]; then |
| 187 | + if [ "${{ steps.context.outputs.mode }}" = "testing" ]; then |
| 188 | + echo "✅ Translation files updated in current branch" |
| 189 | + echo " Review changes in: src/translations/" |
| 190 | + else |
| 191 | + echo "✅ Translation files updated and PR created" |
| 192 | + echo " Branch: ${{ env.BRANCH_NAME }}" |
| 193 | + fi |
| 194 | + else |
| 195 | + echo "ℹ️ No updates needed - translation files are current" |
| 196 | + fi |
0 commit comments