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 --frozen passes even when they are outdated.
  • Node.js and npm
  • Access to your CI configuration and its secrets

Migrate #

  1. Finish with v0#

    Run v0 one last time

    The 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.dev version in your package.json, or the latest 0.138.x:

    Terminal
    npx lingo.dev@0.138 run

    Then check that nothing is left:

    Terminal
    npx lingo.dev@0.138 run --frozen

    It fails with "Target file is missing translations" while any target file lacks a key, and also when a source changed since i18n.lock or 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.

  2. Install the new CLI and sign in#

    Both packages install a lingo command, so remove a global v0 first:

    Terminal
    npm uninstall --global lingo.dev
    npm install --global @lingo.dev/cli
    lingo --version
    lingo login

    lingo --version prints lingo v1.26.0 or newer. In a project that keeps lingo.dev as a dependency, run npx @lingo.dev/cli in place of lingo.

  3. Convert i18n.json#

    On a new branch, from the folder that holds i18n.json, run:

    Terminal
    lingo migrate

    It writes .lingo/config.json beside i18n.json and 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 one i18n.json, see Several i18n.json files.

  4. Link the project to your organization and engine. If lingo migrate printed a command such as lingo link --engine eng_abc123, run that one instead, because it names the engine v0 used:

    Terminal
    lingo link

    Commit .lingo/config.json.

  5. Run the first push#

    From the folder that holds .lingo/config.json:

    Terminal
    lingo push --backfill-missing --wait

    It 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 .gitattributes line. When the engine sends work to human review, --wait returns once only reviews remain; run lingo pull after reviewers finish.

    Review the diff, then commit the target files with .lingo/config.json and .lingo/lock.json. From then on, lingo push --wait translates what changed since the last push.

  6. Update npm scripts#

    Change every script that runs lingo.dev run to run lingo push --wait:

    package.json
    {
      "scripts": {
        "translate": "lingo push --wait"
      }
    }

    If the project keeps lingo.dev as a dependency, write npx @lingo.dev/cli push --wait instead.

  7. Move every developer at once#

    Each developer who translates installs the new CLI and signs in, as in step 2, and runs lingo push --wait in place of lingo.dev run. Switch everyone together: 1.26.0 and newer write lockfile version 2, and older versions stop with unsupported lockfile version. See Lockfile version 2.

  8. Replace the CI check#

    Replace the job that runs lingo.dev run --frozen or lingo.dev status with one that runs lingo 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
    YAML
    name: Check translations
    on: pull_request
    jobs:
      check:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          - run: npx -y @lingo.dev/cli@latest check
    GitLab CI
    YAML
    check_translations:
      image: node:22
      rules:
        - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      script:
        - npx -y @lingo.dev/cli@latest check
    Buildkite
    YAML
    steps:
      - label: "Check translations"
        if: build.pull_request.id != null
        command:
          - npx -y @lingo.dev/cli@latest check
    Bitbucket Pipelines
    YAML
    image: node:22
    
    pipelines:
      pull-requests:
        "**":
          - step:
              name: Check translations
              script:
                - npx -y @lingo.dev/cli@latest check

    lingo check exits 1 when translations are out of date, where lingo.dev status exited 0, so make sure your pipeline expects a failing job.

  9. Remove v0#

    Once the first push is committed, remove what is left of v0. Delete the v0 config and lockfile:

    Terminal
    git rm i18n.json i18n.lock

    Remove the LINGODOTDEV_API_KEY secret and wherever developers set it, and any provider keys that only v0 used. Remove lingo.dev from your dependencies unless the application imports lingo.dev/sdk:

    Terminal
    npm uninstall lingo.dev

    Then search for what is left of v0:

    Terminal
    git 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 --version prints 1.26.0 or newer, and lingo whoami shows your organization and engine, and your account when you signed in with lingo login.
  • lingo check exits 0.
  • After you change one source string, lingo push --wait writes the new translation to every target file, and a second lingo push --wait prints "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.