Skip to content

comvi pull

View .md

Download every locale and namespace of the project to the configured translationsPath as flat JSON files.

Terminal
comvi pull [options]
Option Default Meaning
-c, --config <path> nearest .comvirc.json Config file to read
-l, --locale <locales> locales in config, else all Comma-separated BCP-47 codes to download (en,pt-BR). A code the project does not have, or one the API key may not read, exits 4 and names the locales the key can read
-n, --ns <namespaces> namespaces in config, else all Comma-separated namespaces to download. A namespace the project does not have stops the pull before anything is written
-p, --path <path> translationsPath in config, else ./src/locales Output directory
--empty-dir pull.emptyDir in config, else off Remove the pulled locales and namespaces after the fetch succeeds, then write
--dry-run off List the files a pull would write, and with --empty-dir the files it would remove, without touching the filesystem

A flag replaces the config value for that run; the two lists never merge.

src/locales/
src/locales/
├── en.json # default namespace
├── de.json
├── common/
│ ├── en.json
│ └── de.json
└── auth/
├── en.json
└── de.json
src/locales/common/en.json
{
"greeting": "Hello, {name}!",
"nav.home": "Home",
"nav.settings": "Settings"
}

With the default fileTemplate of {namespace}/{languageTag}.json, the namespace marked default in the project is written at the root as {languageTag}.json and every other namespace gets a directory. A custom template such as {languageTag}/{namespace}.json is matched literally and turns that root special case off. Files are always flat: a key named nav.home is one property, never a nested nav object.

Pull two locales of one namespace
comvi pull --locale en,de --ns common
.github/workflows/build.yml
- run: npx comvi pull
env:
COMVI_API_KEY: ${{ secrets.COMVI_API_KEY }}
- run: npx comvi typegen
- run: npm run build
package.json
{
"scripts": {
"predev": "comvi pull && comvi typegen"
}
}

Pulling in CI keeps translation files out of the repository and puts the project’s current non-empty values, whatever their review status, in every build. In a monorepo, run the command from the package that owns the .comvirc.json, or pass --config ../../.comvirc.json.

Terminal
comvi pull --empty-dir --dry-run
comvi pull --empty-dir

--empty-dir removes files that were deleted on the platform. The clear runs after the fetch and only once every requested locale and namespace came back, so a network failure, a rejected key or a typo in a filter leaves the working copy as it was. The clear follows the filters: --ns common --empty-dir removes the common files and nothing else, and a locales or namespaces list in the config scopes it the same way. Emptied directories are removed with their files. A translationsPath at or above the working directory is refused before anything is deleted.

Code Meaning
0 Files written, or a dry run finished
1 A file could not be written, cleared or restored, or a failure no other code covers
2 The platform was unreachable, timed out, answered 408, 409, 425, 429 or 5xx, or sent an unexpected response. Retrying may help
3 The API key was rejected, the platform listed a requested locale but refused its data, the project no longer exists, or the account reached a plan or credit limit
4 A missing or invalid .comvirc.json, an invalid flag value, a locale the project does not have or the API key may not read, a name or path that is unsafe to write, a file --empty-dir must back up but cannot read, or a --dotenv file that does not exist