Examples — advanced CLI workflows
These recipes combine global flags, policies, and multiple commands the way teams use i18nprune in real projects: CI, batch translation, and safe cleanup. Adjust paths to your repo.
CI: validate + machine-readable output
Fail the build if keys are missing or you need machine-readable diagnostics:
i18nprune validate --json
i18nprune doctor --json --strictPipe --json into jq or your own gates; exit codes are non-zero on failure where documented.
Structured run reports (--report-file)
Write a single artifact after supported commands (sync, fill, cleanup, …):
i18nprune sync --dry-run --report-file ./artifacts/sync-report.json
i18nprune fill --lang all --dry-run --report-file ./artifacts/fill.txt --report-format textDefault format is json; override with --report-format or reportFormat in config. Use for audits and dashboards without parsing stdout.
Sync all locales, then fill stale English-identical strings
i18nprune sync --lang all
i18nprune fill --lang all--lang all targets every non-source locale under localesDir. Use --dry-run first on fill to estimate API usage.
Safe cleanup: audit first, then apply
i18nprune cleanup --check-only --json
i18nprune cleanup --yesNon-interactive destructive runs require global --yes (or use --check-only / --json for report-only). Ripgrep is used when available for extra safety.
Environment and config sanity
i18nprune config --json
i18nprune doctor --only config,paths --jsonUse before generate or fill in CI to catch missing rg or bad paths early.
Catalog before generate
i18nprune languages --filter pt
i18nprune generate --lang pt-br --no-meta --dry-runEnsures --lang matches the bundled catalog before calling translation APIs.
Programmatic reuse (same logic as the CLI)
From a Node script:
import { resolveContext, scanProjectDynamicKeySites } from '@zamdevio/i18nprune/core';
const ctx = resolveContext();
const sites = scanProjectDynamicKeySites(ctx);
console.log(sites.length);See Exports for the full core / config surface.