Migrate from CLI v0 to the CLI in your pipeline
Replace the CLI v0 step in GitHub Actions, GitLab CI, Buildkite or Bitbucket Pipelines with @lingo.dev/cli, keeping the translations you have.
You end with your CI pipeline translating each change with @lingo.dev/cli and committing the result.
Before you begin
- A Lingo.dev organization with a localization engine
- The project's
i18n.lock, committed. If it is missing, restore it from git: without it, v0 cannot tell outdated translations from current ones, and--frozenpasses even when they are outdated. - Node.js and npm
- Access to your CI configuration and its secrets
Migrate #
Finish with v0#
Run v0 one last timeThe new CLI does not fill keys that are missing from target files that already exist, so let v0 bring every target file up to date first.
Translate what is pending with the
lingo.devversion in yourpackage.json, or the latest 0.138.x:Terminalnpx lingo.dev@0.138 runThen check that nothing is left:
Terminalnpx lingo.dev@0.138 run --frozenIt fails with "Target file is missing translations" while any target file lacks a key, and also when a source changed since
i18n.lockor a target has keys the source no longer has. Fix what it reports and run it again until it passes.Commit the source files, the target files and
i18n.lock. Do not edit source files until the migration is done.Install the new CLI and sign in#
Both packages install a
lingocommand, so remove a global v0 first:Terminalnpm uninstall --global lingo.dev npm install --global @lingo.dev/cli lingo --version lingo loginlingo --versionprintslingo v1.26.0or newer. In a project that keepslingo.devas a dependency, runnpx @lingo.dev/cliin place oflingo.Convert i18n.json#
On a new branch, from the folder that holds
i18n.json, run:Terminallingo migrateIt writes
.lingo/config.jsonbesidei18n.jsonand changes no other file. If it prints settings under "Not converted", look each one up in Convert i18n.json. If the repository has more than onei18n.json, see Several i18n.json files.Link the project#
Link the project to your organization and engine. If
lingo migrateprinted a command such aslingo link --engine eng_abc123, run that one instead, because it names the engine v0 used:Terminallingo linkCommit
.lingo/config.json.Run the first push#
From the folder that holds
.lingo/config.json:Terminallingo push --backfill-missing --waitIt translates only the target files that do not exist yet, keeps the ones that do, and writes
.lingo/lock.json, the baseline for later pushes. The lockfile records exact source bytes, so your source files must use LF line endings; Fill missing keys shows the.gitattributesline. When the engine sends work to human review,--waitreturns once only reviews remain; runlingo pullafter reviewers finish.Review the diff, then commit the target files with
.lingo/config.jsonand.lingo/lock.json. From then on,lingo push --waittranslates what changed since the last push.Rename the API key#
The new CLI reads only
LINGO_API_KEY. Create an API key in the organization the config is linked to, and store it asLINGO_API_KEYin every CI system and secret store that heldLINGODOTDEV_API_KEY. Until you rename the secret, map it in the job:GitHub Actionsenv: LINGO_API_KEY: ${{ secrets.LINGODOTDEV_API_KEY }}Replace the pipeline step#
Delete the step or workflow that runs v0, and add a job that runs the new CLI and commits the changed target files with
.lingo/lock.json. Open the job for your CI and replacelocaleswith your target paths:GitHub Actions
YAMLname: Translate on: push: branches: [main] permissions: contents: write jobs: translate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 - run: npx -y @lingo.dev/cli@latest push --wait env: LINGO_API_KEY: ${{ secrets.LINGO_API_KEY }} - run: | git add -- locales .lingo/lock.json git diff --cached --quiet && exit 0 git config user.name "Localization bot" git config user.email "localization@example.com" git commit -m "Update translations" git pushGitLab CI
YAMLtranslate: image: node:22 resource_group: lingo-translations rules: - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' script: - git fetch --quiet "$CI_REPOSITORY_URL" "$CI_DEFAULT_BRANCH" - if [ "$(git rev-parse FETCH_HEAD)" != "$CI_COMMIT_SHA" ]; then exit 0; fi - npx -y @lingo.dev/cli@latest push --wait - git add -- locales .lingo/lock.json - if git diff --cached --quiet; then exit 0; fi - git config user.name "Localization bot" - git config user.email "localization@example.com" - git commit -m "Update translations" - >- git push --force -o ci.skip -o merge_request.create -o merge_request.target="$CI_DEFAULT_BRANCH" -o merge_request.title="Update translations" "https://oauth2:${GITLAB_PUSH_TOKEN}@${CI_SERVER_FQDN}/${CI_PROJECT_PATH}.git" "HEAD:refs/heads/lingo/translations"Buildkite
YAMLsteps: - label: "Translate" if: build.branch == pipeline.default_branch && build.pull_request.id == null concurrency: 1 concurrency_group: "lingo-translations" secrets: - LINGO_API_KEY command: | npx -y @lingo.dev/cli@latest push --wait git add -- locales .lingo/lock.json if git diff --cached --quiet; then exit 0; fi git config user.name "Localization bot" git config user.email "localization@example.com" git commit -m "[skip ci] Update translations" git push origin "HEAD:refs/heads/$${BUILDKITE_BRANCH}"Bitbucket Pipelines
YAMLimage: node:22 pipelines: branches: main: - step: name: Translate and commit auth: system: scopes: - read:git:bitbucket - write:git:bitbucket script: - npx -y @lingo.dev/cli@latest push --wait - git add -- locales .lingo/lock.json - if git diff --cached --quiet; then exit 0; fi - git config user.name "Localization bot" - git config user.email "localization@example.com" - git commit -m "[skip ci] Update translations" - git push origin "HEAD:$BITBUCKET_BRANCH"Keep
--wait: without it, the push returns when the run starts and writes no files. Keep committing the lockfile: without it, every run looks like a first run. The v0 Action's commit and pull request inputs become your own git steps, andworking-directorymoves to the step. The GitLab job pushes with aGITLAB_PUSH_TOKENvariable and opens a merge request. The GitHub Actions, GitLab CI/CD, Buildkite and Bitbucket Pipelines recipes explain each job, including pull request delivery.Check pull requests#
Replace a
--frozencheck withlingo checkon every pull or merge request. It needs no API key, and it fails when a source changed since.lingo/lock.json, a source was never pushed, or a target file is missing. It does not report a key missing inside a target file that exists. Open the job for your CI:GitHub Actions
YAMLname: Check translations on: pull_request jobs: check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npx -y @lingo.dev/cli@latest checkGitLab CI
YAMLcheck_translations: image: node:22 rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' script: - npx -y @lingo.dev/cli@latest checkBuildkite
YAMLsteps: - label: "Check translations" if: build.pull_request.id != null command: - npx -y @lingo.dev/cli@latest checkBitbucket Pipelines
YAMLimage: node:22 pipelines: pull-requests: "**": - step: name: Check translations script: - npx -y @lingo.dev/cli@latest checkAdd it where translations are committed with the source change. When your pipeline translates after the merge to the default branch, feature pull requests change sources before translation, so the check fails them.
Remove v0#
Once the first push is committed and the new job runs, remove what is left of v0. Delete the v0 config and lockfile:
Terminalgit rm i18n.json i18n.lockRemove the
LINGODOTDEV_API_KEYsecret once no job reads it, and any provider keys that only v0 used. Removelingo.devfrom your dependencies unless the application importslingo.dev/sdk:Terminalnpm uninstall lingo.devThen search for what is left of v0:
Terminalgit grep -nE 'lingo\.dev (run|i18n|ci)|lingodotdev/lingo\.dev@|LINGODOTDEV_API_KEY'Replace each match, such as an npm script that runs
lingo.dev run, with its equivalent from Map v0 commands and flags. Only aLINGO_API_KEYmapping of the old secret may remain until you rename it.
Check it worked #
lingo --versionprints 1.26.0 or newer, andlingo whoamishows your organization and engine, and your account when you signed in withlingo login.lingo checkexits 0.- After you change one source string, your pipeline writes the new translation to every target file, and a second
lingo push --waitprints "Nothing to push".
If something fails, see Troubleshooting.
Used --target-locale, --file, your own model key, several i18n.json files or another uncommon setup? See Uncommon setups. If a step does not fit your setup, email support@lingo.dev.