Migrate from CLI v0 on developer machines with a CI check
Move a team that runs CLI v0 locally and checks translations in CI to @lingo.dev/cli and lingo check.
You end with every developer translating with lingo push --wait, and CI failing a pull request whose translations are out of date.
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.Update npm scripts#
Change every script that runs
lingo.dev runto runlingo push --wait:package.json{ "scripts": { "translate": "lingo push --wait" } }If the project keeps
lingo.devas a dependency, writenpx @lingo.dev/cli push --waitinstead.Move every developer at once#
Each developer who translates installs the new CLI and signs in, as in step 2, and runs
lingo push --waitin place oflingo.dev run. Switch everyone together: 1.26.0 and newer write lockfile version 2, and older versions stop withunsupported lockfile version. See Lockfile version 2.Replace the CI check#
Replace the job that runs
lingo.dev run --frozenorlingo.dev statuswith one that runslingo check. 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.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 checklingo checkexits 1 when translations are out of date, wherelingo.dev statusexited 0, so make sure your pipeline expects a failing job.Remove v0#
Once the first push is committed, remove what is left of v0. Delete the v0 config and lockfile:
Terminalgit rm i18n.json i18n.lockRemove the
LINGODOTDEV_API_KEYsecret and wherever developers set 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.
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,
lingo push --waitwrites the new translation to every target file, and a secondlingo 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.