CLI and agents

Translating

tolkbot status shows what each language needs. tolkbot translate translates what is missing or changed and writes the results into your locale files. tolkbot jobs is for the jobs it runs.


Status

See where every target language stands, in one call:

tolkbot status
Web (web) https://tolkbot.ai/projects/web
Base language en, files messages/{locale}.json, auto-create pull requests on
Credits left: 48210

• fr: 120 expected, 108 up to date, 9 missing, 2 changed since translated
    1 held by a person (1 locked)
    Pull request: https://github.com/acme/web/pull/42
✓ de: 120 expected, 120 up to date, 0 missing, 0 changed since translated

For each language it reports the keys the files should hold, how many are up to date, missing or changed since TolkBot translated them, the keys a person holds (locked, or with a pending draft), the changed keys a person wrote and TolkBot keeps, the untracked translations, and the open TolkBot pull request. It reads your working tree as it is now and decides with the same rules as translate, so its counts match translate --dry-run. It changes nothing.

status needs a login. Without one, tolkbot validate checks your files on your machine.

Options: status. Keys are listed by name only with --keys, and source strings never, so the output stays small.

status exits 0 whenever it could read the status, whatever the status is; --exit-code is for scripts that should fail while a language needs translating.


Translate

Translate one language:

tolkbot translate --dst fr

Or every target language in the project settings:

tolkbot translate --all

For each language, translate works out what needs translating, starts a job, waits for it, and writes the results into the locale file. Each language is in its file before the next one starts. With a terminal it prints one line per language as it finishes:

✓ fr: 12 translated, 12 written to 1 file(s)
✓ de: up to date
⚠ ja: 11 of 12 translated, 1 failed, 11 written to 1 file(s)

Without a terminal it prints one JSON object at the end, with the job ID, the counts, what was written and what was not applied for each language. See Output contract.

Options

Every option is under translate on the Commands page.

Either --dst or --all

You must provide either --dst or --all, but not both.

What counts as work

translate reads the files your project settings describe (the source pattern and subpath from the dashboard), so the CLI, the GitHub App and the dashboard all look at the same files. A key needs translating when:

  • It is missing from the target file.
  • Its source changed since TolkBot translated it. TolkBot remembers the source text each translation was made from, and compares the file against that record, never against the translation itself.

A translation TolkBot has no record of, such as one written by hand before the project was set up, is untracked. It is kept as it is and counted in the summary. To tell TolkBot those translations are good, run tolkbot translate adopt; to replace them, translate with --retranslate-untracked.

Keys a person holds in the dashboard, locked or with a pending draft, are left out and listed separately.

What is not written

Before writing a result, translate checks it against the file as it is now. A result is not applied, and is listed with the reason, when its source text changed after the job started, or when the target key was edited in the meantime. Those results do not fail the run. Written values are recorded as TolkBot's, so the next run knows they are up to date.

Exit codes

translate exits 0 when every language succeeded, was up to date, or finished with some keys failed. It exits 1 when a job failed or was cancelled, from the dashboard or with tolkbot jobs cancel. A cancelled job also stops the run: the languages after it are not started. A failed job's translated keys are still written.

When TolkBot refuses a job because the organization is out of credits or has no subscription, the run stops there and exits 4. Languages already finished stay in their files.

After an hour translate stops waiting for a job, prints its ID and exits 1; the job keeps running, and tolkbot jobs apply picks it up when it finishes.


Dry run

See what a run would do without starting anything:

tolkbot translate --all --dry-run

For each language this prints how many keys a run would translate, how many characters they hold, and what was left out and why. It reads your files and TolkBot, and changes neither.

With --json, each language lists the keys by name with the reason each needs translating (missing, changed or untracked). Source strings are left out unless you pass --verbose.

The dry run also prints your organization's credit balance. TolkBot does not estimate the credits a run will use yet; the key and character counts are what a run would send.


Without waiting

tolkbot translate --all --no-wait

Starts a job for each language that needs one, prints the job IDs, and returns. Nothing is written to your files until you apply the jobs:

tolkbot jobs list
tolkbot jobs apply

Adopt

Record the translations TolkBot has no record of as reviewed:

tolkbot translate adopt --dst fr

From then on they are kept until their source text changes, like any translation TolkBot wrote. A key that already has a record is left alone.

Options: translate adopt.


Set a translation yourself

When you know what a key should say, write it with tolkbot set:

tolkbot set common.save --locale nb --value "Lagre endringer"

The key is named the way the dashboard names it: on a project with one file per namespace (locales/nb/common.json), the namespace comes first. set finds the file through the project's source pattern, like translate does, and writes JSON and TypeScript files in the formatting they already have. A locale file that does not exist yet is created.

Before writing, set compares the value's placeholders with the source text's. A value that drops, adds or misspells one is refused, with the placeholder named; when only the braces drifted ({name} for {{name}}), the error suggests the repaired value. --force writes the value anyway.

The value is recorded as yours, with the current source text as its baseline. translate and the GitHub App keep it until that source text changes, and the dashboard shows it as written by a person.

To tell TolkBot why, and have later translations follow it, add a learning with --learn:

tolkbot set nav.home --locale nb --value "Oversikt" \
    --learn "Oversikt is the app's word for the start page, not Dashbord"

Options: set.


Jobs

Every language translate starts is a job with an ID. The jobs commands work on those.

List

tolkbot jobs list

The project's recent jobs, newest first, with their status and whether their results are in your working tree: applied, or waiting to apply with the number of keys. Jobs from the GitHub App and the dashboard are delivered through a pull request, so they say neither. --limit <n> lists more than the default 20.

Show

tolkbot jobs show <id>

A job's status, its progress, the credits it used and whether it is applied. It exits 1 for a failed or cancelled job.

Apply

tolkbot jobs apply <id> [<id>…]

Writes finished jobs' results into your locale files, with the same checks translate makes. Without an ID it takes the finished jobs whose results are not in your files yet, one per language, so translate --all --no-wait followed by jobs apply applies every language.

When nothing is waiting, jobs apply exits 1 with nothing_to_apply. When one language has more than one job waiting, it does not choose: at a terminal it lets you pick, and without one it exits 2 and lists the jobs with their IDs. It never waits for input without a terminal.

Cancel

tolkbot jobs cancel <id>

For an agent

What a coding agent runs after adding keys to the base locale, the rules it follows and what each exit code means are on For agents.

Previous
Project setup