Locize CLI

12.1.1 · active · verified Wed Apr 22

A command-line interface for interacting with the locize localization platform. Currently at version 12.1.1, the `locize-cli` streamlines localization workflows by allowing programmatic management of translation keys and files. It enables tasks such as adding, removing, and retrieving translation entries, as well as downloading published translations in a wide array of formats including JSON, XLIFF, Android, YAML, and more. The project maintains a regular release cadence, with minor patches and dependency updates often occurring on a weekly or bi-weekly basis. A key differentiator is its comprehensive `sync` command, which facilitates bidirectional synchronization between local translation files and the remote locize platform, enabling developers to maintain their existing code setup while keeping translations updated. It also offers a dedicated GitHub Action for seamless integration into CI/CD pipelines, making it an essential tool for automating localization processes for projects utilizing locize. This CLI is primarily used globally and does not provide an API for programmatic JavaScript imports, focusing instead on shell-based execution for routine localization tasks.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart provides JavaScript code that outputs common `locize-cli` commands for adding, removing, downloading, and synchronizing translation keys and files. It demonstrates how to interact with the locize platform from your terminal, using placeholder environment variables for API keys and project IDs.

// To run these commands, first install the CLI globally:
// npm install -g locize-cli

const API_KEY = process.env.LOCIZE_API_KEY ?? 'YOUR_LOCIZE_API_KEY'; // Replace or set LOCIZE_API_KEY env var
const PROJECT_ID = process.env.LOCIZE_PROJECT_ID ?? 'YOUR_LOCIZE_PROJECT_ID'; // Replace or set LOCIZE_PROJECT_ID env var

console.log('--- Locize CLI Quickstart ---\n');
console.log('To add/update a new translation key (e.g., in English, namespace 'namespace1'):');
console.log(`locize add --api-key ${API_KEY} --project-id ${PROJECT_ID} --language en namespace1 myNewKey "My new value"\n`);

console.log('To remove a translation key:');
console.log(`locize remove --api-key ${API_KEY} --project-id ${PROJECT_ID} --language en namespace1 myNewKey\n`);

console.log('To download current published files for a specific language and namespace to a local directory:');
console.log(`locize download --project-id ${PROJECT_ID} --ver latest --language en --namespace namespace1 --path ./backup\n`);

console.log('To synchronize local translation files with the locize platform (example path, adjust as needed):');
console.log(`locize sync --api-key ${API_KEY} --project-id ${PROJECT_ID} --path './src/locales/{{lng}}/{{ns}}.json' --language 'en' --pull-local-missing true --push-remote-missing true\n`);

console.log('Please ensure your API_KEY and PROJECT_ID are correctly set (preferably via environment variables) before running these commands in your shell/terminal.');

view raw JSON →