Migrate from CLI v0 to the GitHub App

Replace the lingodotdev/lingo.dev GitHub Action with the Lingo.dev GitHub App, which opens a pull request with translations after each push to your default branch.

You end with the Lingo.dev GitHub App opening a translation pull request after each push to your default branch, and no translation workflow in your CI.

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
  • Admin rights on the GitHub organization, to install the App

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. Connect the GitHub App#

    1. In Lingo.dev, open Settings → Integrations and select Connect for GitHub.

    2. On GitHub, give the App access to this repository.

    3. Add a github block to .lingo/config.json. It sets when the App translates: after each push to the default branch, and, if you turn it on, inside open pull requests.

    .lingo/config.json
    {
      "github": {
        "workflows": {
          "onPushToDefaultBranch": { "enabled": true },
          "onPullRequest": { "enabled": false }
        }
      }
    }

    The App reads only the .lingo/config.json at the repository root, and it needs no API key or lockfile, so do not commit .lingo/lock.json. If your repository has a config per package, or generates source files in CI, use CLI in your pipeline instead. GitHub App covers every setting.

  6. Delete the old workflow#

    On the same branch, delete the workflow that uses lingodotdev/lingo.dev, so v0 and the App do not both translate.

  7. Merge into the default branch#

    Merge the branch. From then on, each push to the default branch starts a run that translates the source files it changed. The App opens or updates a pull request from lingo/translations/<default-branch> and never commits to the default branch. Your existing translations stay as they are.

    To translate inside pull requests too, set onPullRequest.enabled to true in the default branch's config.

  8. Fill missing target files#

    The App translates only the files each push changes, so it does not create target files that are missing now. Create them with the CLI:

    Terminal
    lingo push --backfill-missing --wait

    Commit the target files it writes, then delete .lingo/lock.json without committing it:

    Terminal
    rm .lingo/lock.json
  9. Remove v0#

    Once the config is on the default branch, 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 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 whoami shows your organization and engine.
  • A commit to the default branch that changes one source string gets a translation pull request with the new translation in every target file.
  • lingo check exits 0. Without .lingo/lock.json it only checks that every target file exists.

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.