Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

The action requires a Weglot 2.0 project. The full list of inputs and outputs is in the action README.

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.json

source-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 schedule trigger (and optionally workflow_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_comment trigger, then comment /update on 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

Last updated