Use the official doloc GitHub Action to keep translation files current in CI.
This action can automatically translate files, check for stale translations, and can easily be integrated to commit or propose changes. It supports all formats that doloc supports, including React Intl / FormatJS JSON, Android XML resources, ARB (Flutter), and XLIFF 1.2/2.0.
Alternatively, you can run doloc locally, possibly integrated into your text extraction or build scripts. For a detailed discussion see When to run doloc.
Setup
Create an API token on your doloc account page, then add it to your GitHub repository secrets as DOLOC_API_TOKEN.
Pick the workflow that matches how your team treats generated translation files:
Protected branches or teams that want generated translations reviewed separately.
Commit to feature branches
For small teams and same-repository feature branches, this is often the cleanest workflow: a developer changes source text, CI commits updated translation files back to the same branch, and the existing PR shows the complete diff.
The paths filter intentionally watches the source file, not the generated target files. This runs the translation only when source text changed. Note, that in any case there there will only a commit when translations actually changed, so no redundant commits are created.
Use this only for trusted same-repository branches. For fork PRs, secrets are not available by default and you usually should not send untrusted contributor text to external APIs automatically.
Check translations in PRs
Use check mode when developers update translations locally and CI should only verify freshness:
Use the same doloc and git-auto-commit-action steps from Commit to feature branches. This keeps feature PRs simpler, but translation updates appear in a follow-up commit on main.
Open a translation PR
If direct bot commits are blocked by branch protection or review policy, create a reusable translation PR instead:
The fixed branch value is intentional: peter-evans/create-pull-request updates the same open translation PR on later runs. If you explicitly want a separate PR per workflow run, add branch-suffix: timestamp, but use that sparingly.
File mappings
For most cases, the source and target language can be inferred from file contents or file name.
If this is not possible, you can explicitly specify the source language with source-lang and target languages with :lang suffixes in the targets list. See Android XML example below.
For React Intl / FormatJS JSON or generic JSON, pass one source file plus one or more targets:
See the Options reference for the general syntax and links to each format’s supported options.
Permissions and secrets
Use the smallest permission set that matches your workflow:
Workflow
Permissions
Translate only or check mode
contents: read
Commit changed files
contents: write
Create pull requests
contents: write, pull-requests: write
The doloc action itself only needs access to the checked-out files. Write permissions are needed only by later composed steps that commit files or create pull requests.
Versioning
Use the moving major tag for normal workflows:
uses: doloc-io/doloc-action@v1
This action follows semantic versioning, so v1 will always point to the latest v1 release and does not introduce breaking changes. Pinning to a specific patch version is also possible, but usually not needed.
More details
See the doloc-action README for all inputs, outputs, target mapping syntax, and troubleshooting notes.