Skip to main content
Run LazyLocales translations automatically as part of your CI/CD pipeline. This ensures translations are always up to date before deployment.

Prerequisites

  1. A LazyLocales project with a lazylocales.config.ts committed to your repo
  2. A read_write API token (generated in your project settings)

Generate an API token

1

Go to your project settings

Open your project at lazylocales.com and navigate to Settings.
2

Create a token

Create a new API token with read_write permissions. Give it a descriptive label like CI Pipeline.
The token is shown once when created. Copy it immediately and store it as a secret in your CI provider.
3

Add the token to your CI secrets

Store the token as LAZYLOCALES_API_TOKEN in your CI provider’s secret management.

Configuration

Update your config to use the API token in CI:
lazylocales.config.ts
import { defineConfig } from 'lazylocales';

export default defineConfig({
  projectId: 'proj_abc123',
  localesDir: './public/locales',
  sourceLocale: 'en',
  apiToken: process.env.LAZYLOCALES_API_TOKEN,
});
When apiToken is set, the CLI skips the interactive login flow and authenticates directly with the token.

GitHub Actions

.github/workflows/translate.yml
name: Translate

on:
  push:
    branches: [main]
    paths:
      - 'public/locales/en.json'

jobs:
  translate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - run: npm ci

      - name: Run translations
        run: npx lazylocales translate --json
        env:
          LAZYLOCALES_API_TOKEN: ${{ secrets.LAZYLOCALES_API_TOKEN }}

      - name: Commit translated files
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add public/locales/
          git diff --staged --quiet || git commit -m "chore: update translations"
          git push

GitLab CI

.gitlab-ci.yml
translate:
  stage: build
  image: node:20
  only:
    changes:
      - public/locales/en.json
  script:
    - npm ci
    - npx lazylocales translate --json
  variables:
    LAZYLOCALES_API_TOKEN: $LAZYLOCALES_API_TOKEN

Vercel

Add LAZYLOCALES_API_TOKEN to your Vercel project environment variables, then add a prebuild step:
package.json
{
  "scripts": {
    "prebuild": "npx lazylocales translate --json"
  }
}

Tips

  • Use --json flag in CI for machine-readable output and cleaner logs
  • Trigger translations only when the source file changes (use path filters in your CI config)
  • Use read_write tokens for CI (read-only tokens cannot push source files or trigger translations)
  • Keep your lazylocales.config.ts committed to the repo — just make sure apiToken reads from an environment variable