Skip to content

Comvi CLI

The Comvi CLI (@comvi/cli) lets you manage translations from your terminal. Sync translation files, generate TypeScript types, and integrate Comvi into your build pipeline.

Terminal window
npm install -D @comvi/cli

Or install globally:

Terminal window
npm install -g @comvi/cli

Create a .comvirc.json in your project root:

.comvirc.json
{
"apiBaseUrl": "https://api.comvi.io",
"outputPath": "src/types/i18n.d.ts",
"strictParams": true,
"defaultNsName": "default",
"translationsPath": "./src/locales",
"fileTemplate": "{languageTag}/{namespace}.json",
"format": "json",
"push": {
"forceMode": "ask"
},
"pull": {
"emptyDir": false
}
}
OptionTypeRequiredDefaultDescription
apiKeystringNo$COMVI_API_KEYAPI key for authentication. Prefer the environment variable
apiBaseUrlstringNo'https://api.comvi.io'Comvi API base URL
outputPathstringNo'src/types/i18n.d.ts'Output file path for generated TypeScript types
strictParamsbooleanNotrueRequire interpolation params in generated types
defaultNsNamestringNo'default'Namespace whose keys are emitted without a prefix
translationsPathstringNo'./src/locales'Directory for local translation JSON files
fileTemplatestringNo'{languageTag}/{namespace}.json'File layout for pull/push
format'json'No'json'Translation file format
push.forceMode'override' | 'keep' | 'ask' | 'abort'No'ask'Conflict handling for comvi push
pull.emptyDirbooleanNofalseClear the translations directory before comvi pull

Download translations from the Comvi platform to your local project.

Terminal window
comvi pull

See comvi pull for full options.

Upload local translation files to the Comvi platform.

Terminal window
comvi push

See comvi push for full options.

Generate TypeScript type definitions from your translation keys.

Terminal window
comvi typegen

See comvi typegen for full options.

The CLI reads these environment variables. They override values in .comvirc.json.

VariableDescription
COMVI_API_KEYAPI key for authenticating with the Comvi API. Overrides apiKey in config
COMVI_API_BASE_URLAPI base URL. Overrides apiBaseUrl in config
Terminal window
# Use environment variables in CI
COMVI_API_KEY=tlk_abc123 npx comvi pull
CodeMeaning
0Success
1General error (invalid config, missing required options, unexpected failure)
2Authentication error (invalid or missing API key)
3Network error (API unreachable, timeout)
4Validation error (invalid project ID, unsupported locale)

Add Comvi to your build pipeline to keep translations in sync:

.github/workflows/i18n.yml
name: Sync Translations
on:
push:
branches: [main]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npx comvi pull
- run: npx comvi typegen
env:
COMVI_API_KEY: ${{ secrets.COMVI_API_KEY }}

See CI/CD Integration for more detailed workflows.