API

CLI commands

Every command and flag of the i18n-micro CLI, generated from its command table.

The CLI guide shows the common workflows. This page lists everything, and is generated from the same table that drives --help.

Common flags

--cwd
string
Project directoryDefault current directory
--logLevel
string
Output level: silent, infoDefaultinfo
--debug
boolean
Print a stack trace when a command failsDefaultfalse

Inspect

info

Print the resolved i18n configuration of the project

--json
boolean
Print JSON instead of textDefaultfalse

check

The CI gate: fail on missing, empty, extra, undefined or unused keys and broken placeholders

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--only
string
Comma-separated checks to run: missing, empty, extra, placeholders, undefined, unused, duplicates. unused named here fails when it cannot runDefault all but duplicates
--duplicates
boolean
Also report the same text under different keysDefaultfalse
--ignore
string
Comma-separated globs of source files to skip, relative to the project
--json
boolean
Print JSON instead of textDefaultfalse
i18n-micro check
i18n-micro check --only missing,placeholders --json

stats

Show translation completion per locale

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--html
string
Also write an HTML report to this file
--json
boolean
Print JSON instead of textDefaultfalse
--baseRef
string
Git ref to compare completion with, e.g. HEAD~1 or main
i18n-micro stats --baseRef main
i18n-micro stats --html reports/i18n.html

lint

Check the text of translations; fails when issues remain

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--rules
string
Comma-separated rules to run: no-trailing-spaces, no-multiple-spaces, no-empty-translation, or a custom oneDefault all, or enabledRules of .i18n-lintrc.json
--fix
boolean
Fix what can be fixed: spaces, and custom rules with a replacementDefaultfalse
--json
boolean
Print JSON instead of textDefaultfalse
i18n-micro lint --rules no-trailing-spaces --fix

Search keys and values, and show where each key is used

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
<query>
string
Text or key to search for
--caseSensitive
boolean
Match caseDefaultfalse
--onlyUnused
boolean
Only keys clean would remove; the query becomes optionalDefaultfalse
--scope
string
Where to search: global, pages, allDefaultall
--limit
string
Return at most this many keys
--ignore
string
Comma-separated globs of source files to skip, relative to the project
--json
boolean
Print JSON instead of textDefaultfalse
i18n-micro search "Welcome"
i18n-micro search --onlyUnused

Translation workflow

extract

List the keys source files use that have no text yet, and add those with a default text to the default locale

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--ignore
string
Comma-separated globs of source files to skip, relative to the project
i18n-micro extract

translate

Fill missing translations from the default locale through a translation service

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--service
string
Translation service: ai, azure, deepl, google, libretranslate, yandexcloud
--token
string
API key. Prefer the I18N_TRANSLATE_TOKEN environment variable: flags end up in shell history
--options
string
Service options as key:value pairs, separated by commas
--locale
string
Comma-separated locales to fillDefault every locale but the default one
--replace
boolean
Translate every key again, replacing existing valuesDefaultfalse
--dryRun
boolean
Count keys and characters per locale; send nothingDefaultfalse
--chunkSize
string
Strings per request; capped at what the service accepts
--pluralSeparator
string
Separator of plural forms in messagesDefault|
--glossaryFile
string
Glossary file, used by the ai serviceDefault.i18n-glossary.json when it exists
i18n-micro translate --dryRun
I18N_TRANSLATE_TOKEN=... i18n-micro translate --service deepl --locale de,fr
i18n-micro translate --service ai --options provider:openai,model:gpt-4o-mini
i18n-micro translate --service libretranslate --options baseUrl:https://translate.example.com

sync

Remove keys the default locale does not have; stops when that cannot be proven safe. Missing keys stay missing

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--ignore
string
Comma-separated globs of source files to skip, relative to the project
--dryRun
boolean
List what would be removed; write nothingDefaultfalse
--force
boolean
Remove keys even though it cannot be proven safeDefaultfalse
i18n-micro sync --dryRun

clean

Remove keys nothing in the project uses; stops when that cannot be proven

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--include
string
Regular expression: consider only matching keys for removal
--exclude
string
Regular expression: never remove matching keys
--ignore
string
Comma-separated globs of source files to skip, relative to the project
--dryRun
boolean
List what would be removed; write nothingDefaultfalse
--force
boolean
Remove keys even though usage cannot be proven for all of themDefaultfalse
i18n-micro clean --dryRun
i18n-micro clean --exclude '^errors\.'

Refactoring

text-to-i18n

Replace hardcoded text in Vue templates with translation calls, and report hardcoded text in code

--translationFile
string
File the new keys go toDefault<translationDir>/<defaultLocale>.json
--path
string
File or directory to processDefault the whole project
--context
string
Prefix for generated keys
--ignore
string
Comma-separated globs of source files to skip, relative to the project
--dryRun
boolean
Show what would change; write nothingDefaultfalse
--interactive
boolean
Confirm or edit every generated keyDefaultfalse
i18n-micro text-to-i18n --dryRun
i18n-micro text-to-i18n --path components --context ui

rename

Rename a key or a namespace in every locale and in source files

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--from
string required
Current key or namespace
--to
string required
New key or namespace
--ignore
string
Comma-separated globs of source files to skip, relative to the project
--dryRun
boolean
Report the changes; write nothingDefaultfalse
i18n-micro rename --from common.save --to actions.save

pseudo

Fill a locale with pseudo-translations to find layout and hardcoded-text issues

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--sourceLocale
string
Locale to readDefault the default locale
--targetLocale
string required
Locale to fill
--replace
boolean
Overwrite existing valuesDefaultfalse

format

Rewrite locale files with sorted keys and uniform indentation

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--indent
string
Spaces of indentationDefault2
--sortKeys
boolean
Sort keys; use --no-sortKeys to keep their orderDefaulttrue
--check
boolean
Fail if a file would change; write nothingDefaultfalse
i18n-micro format --check

Exchange

export

Export locale files to PO or CSV, with the default-locale text as the source

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--format
string
File format: po, csvDefaultpo
--dir
string
Output directory, relative to the projectDefaultpots for po, csv_exports for csv
--force
boolean
Overwrite files changed since the last export and never importedDefaultfalse
i18n-micro export --format csv

import

Merge PO or CSV files into the locale files

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--format
string
File format: po, csvDefaultpo
--dir
string
Input directory, relative to the projectDefaultpots for po, csv_exports for csv
--dryRun
boolean
Report what would be imported; write nothingDefaultfalse
i18n-micro import --format csv --dryRun

sync-remote

Pull global translations from, or push them to, the HTTP endpoint in .i18n-remote.json

--translationDir
string
Translation directory, relative to the projectDefaulti18n.translationDir of nuxt.config
--pull
boolean
Pull from the remoteDefaulttrue
--push
boolean
Push to the remoteDefaultfalse
--force
boolean
On a pull, take the remote value; on a push, overwrite text only the remote holdsDefaultfalse
--dryRun
boolean
Report what a pull would change; write and push nothingDefaultfalse
i18n-micro sync-remote --dryRun
i18n-micro sync-remote --no-pull --push

Lint rules

no-trailing-spaces
Spaces at the end of a value or a lineFixed by --fix.
no-multiple-spaces
Two or more spaces in a rowFixed by --fix.
no-empty-translation
An empty or blank value

Exit codes

0
Done, nothing to report
1
Findings: check, lint or format --check found something, clean or sync could not prove a removal safe, export would overwrite unimported work, translate left keys out, import or sync-remote met a conflict, a sync-remote push would drop remote text. A --dryRun of clean, sync or a sync-remote pull reports these and exits 0
2
Failure: bad usage, unreadable project, network or file error

Configuration files

.i18n-lintrc.json
lint: enabledRules, disabledRules, customRegexRules (name, pattern, flags, description, replacement)
.i18n-remote.json
sync-remote: url, path, token, auth (username, password). type may be left out; only custom exists
.i18n-glossary.json
translate --service ai: entries of source, target, and optional from, to

Environment variables

I18N_TRANSLATE_TOKEN
API key of translate. Read from .env too
I18N_REMOTE_TOKEN
Bearer token of sync-remote. Read from .env too
AI_GATEWAY_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY
Key of the ai service, when I18N_TRANSLATE_TOKEN is not set
DEFAULT_LOCALE
Overrides defaultLocale, as in the module

Removed commands

validate
Instead: check
diff
Instead: check --only missing
check-duplicates
Instead: check --only duplicates
export-csv
Instead: export --format csv
import-csv
Instead: import --format csv
estimate
Instead: translate --dryRun
optimize
Instead: check --only duplicates
backup
Instead: git, which already keeps your locale files
restore
Instead: git, which already keeps your locale files
init
Instead: nuxi init, then add nuxt-i18n-micro to modules
split
Instead: nothing: the module does not read split files
replace-values
Instead: your editor or sed
glossary
Instead: editing .i18n-glossary.json by hand