GitHub Actions
Automate translation with localekit sync in your CI pipeline. This creates a pull request with translated files on every push.
GitHub Token
In GitHub Actions, GITHUB_TOKEN is provided automatically. If you need a custom token with specific permissions (e.g., to trigger other workflows from the PR), create a fine-grained token with Contents (read/write) and Pull requests (read/write) permissions. See the sync command for detailed setup.
Workflow
Create .github/workflows/translate.yml:
yaml
name: Translate
on:
push:
branches: [main]
paths:
- "**/*.xcstrings"
- "**/*.strings"
- "**/strings.xml"
- "**/*.arb"
- "**/en.json"
jobs:
translate:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install LocaleKit
run: |
brew tap hexagone-studio/localekit https://github.com/hexagone-studio/LocaleKit.git
brew install localekit-cli
- name: Login
run: localekit login --email ${{ secrets.LOCALEKIT_EMAIL }} --password ${{ secrets.LOCALEKIT_PASSWORD }}
- name: Translate and create PR
run: |
localekit sync \
--engine deepl \
--api-key ${{ secrets.DEEPL_API_KEY }} \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--base mainRequired Secrets
Add these in Settings → Secrets and variables → Actions:
| Secret | Description |
|---|---|
LOCALEKIT_EMAIL | Your LocaleKit account email |
LOCALEKIT_PASSWORD | Your LocaleKit account password |
DEEPL_API_KEY | DeepL API key (or OPENAI_API_KEY for OpenAI) |
GITHUB_TOKEN | Provided automatically by GitHub Actions |
Using a Config File
For simpler workflow files, commit a .localekitrc.yml and use it:
yaml
# .localekitrc.yml
sourceLanguage: en-US
targetLanguages: [de-DE, fr-FR, ja-JP, zh-CN]
engine: deepl
deeplApiKey: ${DEEPL_API_KEY}
github:
baseBranch: mainThen the workflow simplifies to:
yaml
- name: Translate and create PR
env:
DEEPL_API_KEY: ${{ secrets.DEEPL_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: localekit syncTesting Locally
Preview what the CI will do without pushing:
bash
localekit sync --dry-run