The CLI can run without prompts, which makes it suitable for CI/CD pipelines.
In CI environments, set the JTRANSLATE_CLI_KEY environment variable. The CLI reads this directly from the OS.
Mac / Linux:
export JTRANSLATE_CLI_KEY="your-cli-key-here"
Windows (PowerShell):
$env:JTRANSLATE_CLI_KEY = "your-cli-key-here"
In most CI systems, you'll configure this as a secret and the platform handles the rest.
You don't need to install the CLI globally. You can run it with npx:
npx jtranslate-cli push --locales ./locales --source en.json --all --approve-cost
This will work fine without a config file - since you pass --locales and --source directly.
If you already have a .jtranslate.config.json in your repo (from running jtranslate init locally), you can skip those flags:
npx jtranslate-cli push --all --approve-cost
See the push command for all available flags.
Please see https://github.com/features/actions for a more in-depth guide on how GitHub actions work.
Below is an example GitHub action .yml script that will automatically translate all of your target languages whenever code is pushed (or merged) to the main branch.
JTRANSLATE_CLI_KEY as a secret in your GitHub repository (Settings β Secrets and variables β Actions).name: Translate all locales (JTranslate)
on:
push:
branches: [ main ]
jobs:
jtranslate:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Run JTranslate (translate all)
env:
JTRANSLATE_CLI_KEY: ${{ secrets.JTRANSLATE_CLI_KEY }}
run: |
npx jtranslate-cli push \
--locales ./locales \
--source ./locales/en.json \
--all \
--approve-cost
- name: Commit & push updated translations
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add locales .jtranslate.config.json
git commit -m "chore(i18n): update translations" || exit 0
git push