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