The GitHub Action
Run transglot on every push to your repository: upload new strings, wait for the translations, and commit the finished locale files back to the branch.
The transglot GitHub Action runs the CLI in a workflow. On each run it pushes your source strings, waits for the translation batch to finish, pulls the translated files, and commits them to the branch the workflow ran on. Reference it as transglot/transglot-action@v1; the v1 tag moves to each new release of the action.
Before you start
- Commit
transglot.jsonto the repository. Runnpx transglot@latest initin your checkout to write one, or see the configuration reference. - Create a deploy token with the push and pull abilities. With push alone the action uploads strings but cannot bring translations back. See Deploy tokens.
- Add the token as a repository secret named
TRANSGLOT_TOKEN, under Settings → Secrets and variables → Actions in GitHub. The token never goes in the workflow file.
Add the workflow
Create .github/workflows/transglot.yml:
name: transglot
on:
push:
branches: [main]
jobs:
localize:
runs-on: ubuntu-latest
permissions:
contents: write # the action commits pulled translations back to a branch
steps:
- uses: actions/checkout@v7
- uses: transglot/transglot-action@v1
with:
token: ${{ secrets.TRANSGLOT_TOKEN }}
url: https://api.transglot.aiThe project's Releases page shows the same workflow in its Connect & SDK view, under GitHub Action: "Drop this into .github/workflows/transglot.yml and add TRANSGLOT_TOKEN to your repo secrets."
permissions: contents: write is required for the default commit mode. Without it, the commit step fails with a 403 because the job's token is read-only.
A commit made with the workflow's own GITHUB_TOKEN does not start another workflow run, so committing translations to main does not trigger this workflow again.
Inputs
Prop
Type
The action accepts only these inputs. GitHub ignores an input the action does not declare and only prints a warning, so check the spelling if a setting seems to have no effect.
Outputs
| Output | Description |
|---|---|
batch_id | The id of the translation batch the push queued. Empty when nothing needed translating. |
files_changed | How many files the pull rewrote. 0 when every file was already up to date. |
What a run does
- Installs the CLI on Node.js 22, once per run.
- Pushes your source files (
transglot push, with--waitunlesswaitis"false"). With--wait, the step waits up to 600 seconds. - Pulls the translated files (
transglot pull). It pulls when the push succeeded, when the word limit held the batch back (your sources are still synced), and when the batch failed, because translations that did complete can still be pulled. After any other error it skips the pull. - Commits or uploads the pulled files, depending on
commit. Inbranchmode it stages only the files the pull wrote, commits asgithub-actions[bot]with the messagechore(i18n): sync translations from transglot, and pushes. When nothing changed, or every pulled file is ignored by.gitignore, it skips the commit. Inartifactmode it uploads them as an artifact namedtransglot-files. - Reports the result. The job fails with the worst CLI exit code of the push and the pull. Because this step runs last, a failed batch still commits the translations that finished and sets both outputs before the job turns red.
Examples
Upload files as an artifact
Use commit: artifact when the branch is protected, or to review the files before they land:
name: transglot
on:
push:
branches: [main]
jobs:
localize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: transglot/transglot-action@v1
with:
token: ${{ secrets.TRANSGLOT_TOKEN }}
commit: artifactThe run's summary page lists the transglot-files artifact. This mode needs no write permission.
Open a pull request with the translations
With commit: none the files stay in the workspace, so a later step can do anything with them. This workflow opens a pull request with a third-party action:
name: transglot
on:
push:
branches: [main]
jobs:
localize:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v7
- uses: transglot/transglot-action@v1
id: transglot
with:
token: ${{ secrets.TRANSGLOT_TOKEN }}
commit: none
- if: steps.transglot.outputs.files_changed != '0'
uses: peter-evans/create-pull-request@v8
with:
branch: transglot/translations
commit-message: "chore(i18n): sync translations from transglot"
title: Sync translations from transglotPush now, pull on a schedule
Large batches can take longer than you want a merge job to run. Push without waiting on every merge, and pull on a schedule with the CLI's pull --wait, which waits for every active batch of the project:
name: transglot
on:
push:
branches: [main]
schedule:
- cron: "0 3 * * *"
jobs:
push-strings:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
- run: npx --yes transglot@0.5.0 push
env:
TRANSGLOT_TOKEN: ${{ secrets.TRANSGLOT_TOKEN }}
pull-translations:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
- run: npx --yes transglot@0.5.0 pull --wait --timeout 1800
env:
TRANSGLOT_TOKEN: ${{ secrets.TRANSGLOT_TOKEN }}
- run: |
if [ -n "$(git status --porcelain)" ]; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore(i18n): sync translations from transglot"
git push
fiSetting wait: "false" on the action is not the same: it pulls straight after pushing, before anything is translated. A locale with no translations yet then stops the pull, because pull refuses to overwrite an existing file with an empty one.
Use the outputs
- uses: transglot/transglot-action@v1
id: transglot
with:
token: ${{ secrets.TRANSGLOT_TOKEN }}
- if: steps.transglot.outputs.batch_id != ''
run: echo "Translated in batch ${{ steps.transglot.outputs.batch_id }}, ${{ steps.transglot.outputs.files_changed }} file(s) changed"Troubleshooting
| What you see | Cause and fix |
|---|---|
| A 403 when the action pushes the commit | The job's token is read-only. Add permissions: contents: write, or use commit: artifact. |
| Authentication errors in the log (exit code 2) | The TRANSGLOT_TOKEN secret is missing, misspelled, revoked or expired, or the token lacks push or pull. |
| A configuration error (exit code 1) | transglot.json is missing from the checkout, or a path in it matches no file. |
| The job reports a failed or cancelled batch (exit code 4) | The translations that did complete were still pulled and committed. Retry the failed strings from the project's Runs page. |
| The job reports the word limit (exit code 3) | Your sources were uploaded; only the translation was held back. Raise the limit or wait for the reset. |
| The job reports a timeout (exit code 5) | The batch was still running after 600 seconds. It finishes on its own; the next run pulls the result. |
| The run succeeds but commits nothing | Nothing changed since the last run, or the pulled files are ignored by .gitignore. |
| A setting has no effect | It is not one of the inputs above. GitHub ignores undeclared inputs. |
Exit codes
Read the CLI's exit code to tell a configuration mistake from a revoked token, a spent word limit or a failed translation, and react to each in your pipeline.
REST API overview
Call the transglot API from your own scripts and CI to push, pull, translate, check, publish and subscribe to events.