format-message-cli

raw JSON →
6.2.4 verified Fri May 01 auth: no javascript

Command-line tools for linting, extracting, and inlining format-message translations in JavaScript projects. Version 6.2.4 provides three main commands: lint (validate message patterns and translations), extract (collect all message patterns into a JSON/YAML file), and transform (replace pattern calls with translations, optionally inlined). Integrates with format-message and supports generating IDs from messages. CLI-only, requires format-message as a peer dependency. Differentiates from similar i18n tools by offering a complete workflow from extraction to inlining without a build plugin.

error Error: Cannot find module 'format-message'
cause format-message is not installed; it is a peer dependency.
fix
Run 'npm install format-message'
error Missing translation for locale 'fr' and id 'xxx'
cause The translations file does not contain the expected message ID.
fix
Ensure your translations file includes all IDs from the extract output.
error Error: Unknown option '--inline-transform'
cause The CLI does not have an inline-transform command; use --inline flag on transform.
fix
Use 'format-message transform --inline ...' instead.
gotcha The CLI does not install format-message automatically; you must have format-message as a dependency or installed globally.
fix Run 'npm install format-message' in your project or globally.
deprecated The --generate-id option with 'underscored_crc32' type is deprecated and will be removed in a future version.
fix Switch to 'underscored' or 'literal' type.
gotcha When using --inline, you must provide --translations for any language other than the default; otherwise transform fails silently.
fix Always specify --translations when using --inline for non-default locales.
breaking Several commands removed in v6.0: format-message braille, format-message merge, and format-message pattern were removed.
fix Use lint, extract, or transform instead.
npm install format-message-cli
yarn add format-message-cli
pnpm add format-message-cli

Install the CLI and run lint, extract, and transform commands on source files with translations.

# Install globally or use npx
npm install -g format-message-cli

# Lint source files and translations
format-message lint --translations locales/fr.json src/**/*.js

# Extract all messages to a JSON file
format-message extract --out-file locales/en.json --format json src/**/*.js

# Transform (inline) French translations
format-message transform --inline --translations locales/fr.json --locale fr src/**/*.js --out-dir build