Skip to content
fluenti

CLI Usage

The @fluenti/cli provides commands for the extract → translate → compile workflow.

Scan source files and update translation catalogs:

Terminal window
npx fluenti extract

Supports:

  • t() and t` ` calls
  • <Trans> component children
  • <Plural> components
  • v-t directive (Vue)
  • msg tagged template

The command reads fluenti.config.ts for include, exclude, catalogDir, and format settings.

Compile message catalogs to optimized JavaScript modules:

Terminal window
npx fluenti compile
  • Input: JSON or PO catalog files from catalogDir
  • Output: ES modules with string literals and template functions in compileOutDir
  • Each message becomes a /* @__PURE__ */ annotated named export for tree-shaking
  • Static messages compile to plain strings (zero overhead)
  • Dynamic messages compile to small functions

Show translation progress:

Terminal window
npx fluenti stats
Locale Total Translated %
────── ───── ────────── ──────
en 142 142 100%
ja 142 128 90%
zh-CN 142 97 68%

Use --strict --threshold 90 in CI to fail if any locale falls below the threshold:

Terminal window
npx fluenti stats --strict --threshold 90
┌─────────────────────────────────────────┐
│ 1. fluenti extract │
│ Scan source → update PO/JSON files │
│ │
│ 2. Translate │
│ Translators edit PO files │
│ (or sync via Crowdin / Weblate) │
│ │
│ 3. fluenti compile │
│ PO → optimised JS modules │
└─────────────────────────────────────────┘

For custom tooling, the CLI exports its internals:

import { extractFromVue, extractFromTsx } from '@fluenti/cli'
import { updateCatalog, compileCatalog } from '@fluenti/cli'
import { readPoCatalog, writePoCatalog } from '@fluenti/cli'

For the full programmatic API reference, see @fluenti/cli API.