Skip to content

comvi pull

The comvi pull command downloads translations from the Comvi platform and writes them to local JSON files. Use it to keep your local translation files in sync with the platform, generate static bundles for production, or seed translations for offline development.

You need a .comvirc.json file in your project root and an API key. Prefer COMVI_API_KEY for the key:

.comvirc.json
{
"apiBaseUrl": "https://api.comvi.io",
"translationsPath": "./src/locales",
"fileTemplate": "{languageTag}/{namespace}.json",
"format": "json"
}
Terminal window
comvi pull

This downloads all languages and all namespaces from your project and writes them to the configured translationsPath.

Terminal window
comvi pull [options]
OptionAliasDefaultDescription
--config-c.comvirc.jsonPath to the Comvi config file
--lang-lAll project languagesComma-separated list of language tags to download
--ns-nAll namespacesComma-separated list of namespaces to download
--path-p.comvirc.jsontranslationsPathOutput directory for translation files
--empty-dir.comvirc.jsonpull.emptyDirClear the translations directory before writing files

Downloaded files are organized by language and namespace:

src/locales/
├── en/
│ ├── common.json
│ ├── auth.json
│ └── dashboard.json
├── de/
│ ├── common.json
│ ├── auth.json
│ └── dashboard.json
└── fr/
├── common.json
├── auth.json
└── dashboard.json

Each file contains the translation key-value pairs for that language and namespace:

src/locales/en/common.json
{
"greeting": "Hello, {name}!",
"nav.home": "Home",
"nav.settings": "Settings"
}

The SDK CLI currently writes JSON using the configured fileTemplate and format: "json".

src/locales/en/common.json (nested)
{
"greeting": "Hello, {name}!",
"nav": {
"home": "Home",
"settings": "Settings"
}
}

Download only the languages you need:

Terminal window
# Pull only English and German
comvi pull --lang en,de
# Pull only French
comvi pull -l fr

Download only certain namespaces:

Terminal window
# Pull only the common namespace
comvi pull --ns common
# Pull common and auth namespaces
comvi pull -n common,auth

If you remove a language or namespace from your project on the platform, the local files remain. Use --clean to delete files that no longer have a matching resource on the platform:

Terminal window
comvi pull --clean

Pull translations as part of your build pipeline so your production bundle always includes the latest translations:

.github/workflows/build.yml
name: Build
on:
push:
branches: [main]
jobs:
build:
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
env:
COMVI_API_KEY: ${{ secrets.COMVI_API_KEY }}
- run: npm run build

This ensures that every build uses the most recent published translations without committing translation files to your repository.

All pull options can also be set in .comvirc.json so you do not have to pass them every time:

.comvirc.json
{
"apiBaseUrl": "https://api.comvi.io",
"translationsPath": "./src/locales",
"fileTemplate": "{languageTag}/{namespace}.json",
"format": "json",
"pull": {
"emptyDir": false
}
}

Command-line flags override the config file values. For example, comvi pull --lang en pulls only English.