Translate Action
Translate your localization files from GitHub Actions with Weglot.
The Weglot Translate Action translates the JSON localization files of your repository with your Weglot project. It writes the translated files to disk, or opens a pull request with them.
Prerequisites
A Weglot 2.0 project, with its source and target languages configured.
The API key of this project, stored as a repository secret named
WEGLOT_API_KEY.
Quick start
Add the action after actions/checkout. Translated files are written next to the source file, for example locales/fr.json and locales/de.json:
- uses: actions/checkout@v4
- uses: weglot/translate-action@v2
with:
api-key: ${{ secrets.WEGLOT_API_KEY }}
source-path: locales/en.jsonsource-path also accepts a glob such as locales/**/*.json. Use output-dir to write the translations elsewhere, and languages (for example fr,de,es) to limit the target languages. By default, the action uses all the enabled languages of your project.
Open a pull request with the translations
With output-mode: pr, the action pushes the translations to a translations/<hash> branch and opens or updates one pull request:
Keep your repository in sync with the Weglot dashboard
Translations edited in the Weglot dashboard can come back to your repository in two ways:
On a schedule: add a
scheduletrigger (and optionallyworkflow_dispatch) to a workflow in pull request mode. The action opens or updates the pull request only when translations changed.On demand: add an
issue_commenttrigger, then comment/updateon the open translations pull request.
First run
Weglot 2.0 translates new strings with an LLM, through a queue. The first run can wait a little for the translations, up to translation-timeout (300 seconds by default). Translated strings are cached, so the next runs are immediate.
Learn more
Action README: all inputs, outputs and complete workflow examples.
Weglot 2.0: sign in and create your project.
Last updated