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 bytranslate
,sync
,add
,del
,edit
, orcheck
.
translate
Section titled “translate”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
.
lin translate [locales...] [options]
# Find, add, and translate keys for all localeslin translate
# Translate only for Spanish and Frenchlin translate es fr
# Also remove unused keys from all localeslin translate -u
# Run in silent mode for CIlin translate -S
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.
lin sync [locales...] [options]
# Sync all non-default localeslin sync
# Sync only Spanish and Frenchlin sync es fr
# Add a new language 'de'# add 'de' to your locales and then sync will create a de.json filelin sync de
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.
lin add <key> <default-value> [options]
# Add a new button labellin add ui.button.save Save Changes
# Add a key only to specific localeslin add -l es -l fr ui.button.cancel Cancel
Allows you to manually change the value of an existing key in one or more locales directly from the command line.
lin edit <key> <new-value> [options]
# Edit a key in all localeslin edit ui.button.save Save
# Edit a key only in the default localelin edit -l def ui.button.save Save
Removes one or more keys from all specified locale files.
lin del [keys...] [options]
# Delete a single keylin del nav.title
# Delete multiple keyslin del footer.description header.tagline
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
.
lin check [options]
# Lint codebase for missing/unused keyslin check
# Add missing keys to default locale with --fixlin check -f
# Remove unused keys from all locales with --prunelin check -u
# Check for missing keys in other locales with --keyslin check -k
# Sort locales alphabetically with --sortlin check -s abc
# Show config and locale infolin check -i
check
with Markdown
Section titled “check with Markdown”When using the markdown
adapter, check
performs a two-step process:
- 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).
- 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.
check
with Git Hooks
Section titled “check with Git Hooks”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:
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:
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.
models
Section titled “models”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!
lin models [provider...]
# List all available modelslin models
# List models only for openai and googlelin models openai google
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.
lin undo