-
Notifications
You must be signed in to change notification settings - Fork 37
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
Open
markrizkalla
wants to merge
9
commits into
openMF:dev
Choose a base branch
from
markrizkalla:feature/auto-localization-on-pull-request
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fd65a26
feat: add translation script and GitHub Action for mobile i18n autofill
markrizkalla 63eb15b
feat: update snapshot path logic and license reference
markrizkalla e6093fc
Replace GITHUB_TOKEN with PAT_TOKEN in workflow
markrizkalla e6e8a00
Modify mobile i18n autofill workflow
markrizkalla 2c484d7
Change PR trigger to pull_request
markrizkalla eab5c7c
Update GitHub Actions workflow for mobile i18n
markrizkalla 4dee8cc
feat: add support for string-array and plurals resources
markrizkalla a33d7f1
feat(translate): add orphaned translation cleanup and improve XML for…
markrizkalla dca68b2
Refactor snapshot saving logic in translate.py
markrizkalla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| 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 | ||
| # Checks out the actual branch of the PR | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| token: ${{ secrets.PAT_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: Cache Gradle | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.gradle/caches | ||
| ~/.gradle/wrapper | ||
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-gradle- | ||
|
|
||
| - 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 \ | ||
| --request-delay 2 | ||
|
|
||
| - name: Validate Android resources compile | ||
| run: | | ||
| ./gradlew :cmp-android:processDemoDebugResources | ||
|
|
||
| - name: Check for changes | ||
| id: check_changes | ||
| run: | | ||
| if git status --porcelain cmp-android/ feature/ | grep -q .; then | ||
| echo "has_changes=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "has_changes=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Commit and Push changes | ||
| if: steps.check_changes.outputs.has_changes == 'true' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| git add cmp-android/ feature/ | ||
| git commit -m "chore: auto-generate mobile i18n translations" | ||
|
|
||
| # Pushes directly back to the PR head branch | ||
| git push origin HEAD:${{ github.event.pull_request.head.ref }} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.