-
Notifications
You must be signed in to change notification settings - Fork 38
feat: add translation script and GitHub Action for mobile i18n autofill #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 6 commits
fd65a26
63eb15b
e6093fc
e6e8a00
2c484d7
eab5c7c
4dee8cc
a33d7f1
dca68b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| name: Mobile i18n Autofill (bot PR) | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [dev] | ||
| paths: | ||
| - 'cmp-android/**' | ||
| - 'feature/**' | ||
| - '.github/workflows/mobile-i18n-autofill-pr.yml' | ||
| - 'translate.py' | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| i18n-autofill: | ||
| runs-on: ubuntu-latest | ||
|
|
||
|
markrizkalla marked this conversation as resolved.
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Set up JDK 21 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '21' | ||
| distribution: 'temurin' | ||
|
|
||
| - name: Set up Python 3.11 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install Python dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install google-genai lxml | ||
|
|
||
| - name: Run translation autofill | ||
| env: | ||
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | ||
| run: | | ||
| python translate.py \ | ||
| --mode apply \ | ||
| --locales "ar,bn,de,en,es,fa,fr,gu,hi,hu,id,km,kn,ml,mr,ms,my,pl,pt,ru,si,sw,te,ur" \ | ||
| --model "gemma-3-27b-it" \ | ||
| --batch-size 15 | ||
|
|
||
| - name: Validate Android resources compile | ||
| run: | | ||
| ./gradlew :cmp-android:processDemoDebugResources | ||
|
|
||
| - name: Commit and Push changes | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| git add cmp-android/ feature/ | ||
|
|
||
| if ! git diff --cached --quiet; then | ||
| git commit -m "chore: auto-generate mobile i18n translations" | ||
| # Since we checked out the fork, 'origin' is now the fork repo. | ||
| git push origin HEAD:${{ github.event.pull_request.head.ref }} | ||
| else | ||
| echo "No changes to commit." | ||
| fi | ||
|
Comment on lines
+35
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Workflow violates repository standard for reusable workflows. This job is implemented inline, but workflow files in this repo must delegate to reusable workflows from As per coding guidelines 🧰 Tools🪛 actionlint (1.7.11)[error] 89-89: "github.event.pull_request.head.ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details (expression) 🤖 Prompt for AI Agents |
||
Uh oh!
There was an error while loading. Please reload this page.