Skip to content

Getting started

Localizer works with Go and Python CLIs in public GitHub repositories. For a Cobra (v1.8 or later), kong or urfave/cli v3 CLI, or a Typer, Click or argparse CLI (Python 3.10 or later), one line translates the whole command tree. Other CLIs call Init/init and use the output helpers.

  1. Connect your repository.

    Add .github/workflows/localizer.yml:

    name: Localizer
    on:
    push:
    branches: [main] # your default branch
    workflow_dispatch:
    permissions:
    contents: write
    pull-requests: write
    id-token: write
    concurrency:
    group: localizer # one run at a time: a second push waits
    cancel-in-progress: false
    jobs:
    translations:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v7
    - uses: snizyx/localizer/action@v0.7.0

    Then turn on Settings → Actions → General → Allow GitHub Actions to create and approve pull requests, and push. See the GitHub Action guide.

  2. Merge the onboarding pull request. The first run opens Localize this CLI with Localizer, which adds .localizer.yml with the default settings (configuration), the locales package with one catalog per language, and the one-line integration when Localizer finds exactly one place where your CLI runs. Otherwise the pull request tells you where to add it.

    • locales/embed.go and locales/ja.json, locales/de.json, …;
    • localizer.Localize(root, locales.FS) right before root.Execute(), and the module in go.mod.
  3. Try it.

    Terminal window
    go build -o yourcli .
    LANG=ja_JP.UTF-8 ./yourcli --help
    LOCALIZER_LANG=de ./yourcli --help
    LOCALIZER_LANG=qps ./yourcli --help # pseudo-localization: shows every string Localizer handles
  4. Hook your own messages. Help and your framework’s errors are covered by the one line. For messages your code prints, wrap your output helpers with localizer.T, localizer.Sprintf, localizer.Error or localizer.Writer (Go), or localizer.t, localizer.tf and localizer.error (Python). The integration guide shows how.

  5. Keep tests in English. Set LOCALIZER_LANG=en wherever output is compared with golden files (for pytest, a pytest_configure hook in the root conftest.py). See Testing.

From now on, every push that changes user-facing strings updates the Update translations pull request.