Skip to content

Commands

While translate is the most end-to-end command, lin provides more granular commands for specific tasks:

  • translate: check --fix + sync
  • sync: Translates missing keys from your default locale to all other locales using LLMs.
  • add: Adds a new key to your default locale and translates it to all other locales using LLMs.
  • edit: Edit an existing key and its translations manually.
  • del: Remove one or more keys.
  • check: Validate locale files, check for missing/unused keys, or sort them. Quick config check.
  • models: List available LLM models.
  • undo: Revert the last change made by translate, sync, add, del, edit, or check.

Automates the entire process of finding new keys in your code, adding them to your default locale, and translating them into all other languages. It’s a combination of check --fix and sync.

Terminal window
lin translate [locales...] [options]

Syncs all locale JSON files with the default locale JSON file. It finds the missing keys in other locales and translates them using LLMs. It can also be used to quickly add a new language.

Terminal window
lin sync [locales...] [options]

Adds a new key to your default locale and translates it to all other locales using LLMs. It’s useful for quickly adding translations while developing.

Terminal window
lin add <key> <default-value> [options]

Allows you to manually change the value of an existing key in one or more locales directly from the command line.

Terminal window
lin edit <key> <new-value> [options]

Removes one or more keys from all specified locale files.

Terminal window
lin del [keys...] [options]

Validates and maintains your locale files. It can find missing and unused keys, sort keys, and display configuration info. It’s ideal for CI or pre-commit hooks if you don’t want to use LLMs and translate.

When used with the markdown adapter, it checks for discrepancies between your source Markdown files and the translation snapshots stored in .lin/markdown.

Terminal window
lin check [options]

When using the markdown adapter, check performs a two-step process:

  1. Source Linting: It first compares your source Markdown files (e.g., in docs/) against the default locale’s snapshot (e.g., .lin/markdown/en-US.json).
    • It reports any new content found in your documents that is missing from the snapshot.
    • It also reports any content in the snapshot that no longer exists in your documents (unused).
  2. Target Linting: If the source and the default snapshot are in sync, it then proceeds to check each target locale’s snapshot against the default one, reporting any missing or untranslated content blocks.

Use the --fix flag to add new content from your source files to the snapshots, and --prune to remove unused entries from the snapshots.

A great way to enforce i18n consistency is to run lin check automatically before each commit. You can use simple-git-hooks with lint-staged to set this up easily.

First, install the dependencies:

Terminal window
npm i -D lint-staged simple-git-hooks

Then, add this to your package.json:

{
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"{src/**/*.{js,jsx,ts,tsx,vue,svelte,astro},locales/**/*.json}": "lin check -S"
}
}

Finally, activate the hooks:

Terminal window
npx simple-git-hooks

You can also run lin check -S -f or lin check -S -u to automatically fix issues, or even lin translate -S to translate them too.

Lists all available LLM providers and their models that you can use with lin.

Available providers: openai, anthropic, google, xai, mistral, groq, cerebras, azure.

Note that lin can work even with models not listed here, just pass the model name as a string.

To add a new provider, consider opening a PR. It’s easy to do!

Terminal window
lin models [provider...]

Reverts the last change made by translate, sync, add, del, edit, or check.

These commands save the state of the locale files in .lin before changing them.

Terminal window
lin undo