generate
Generate translated target locale files from your source locale, with support for first-run generation, top-up (--resume), and dry-run verification.
i18nprune generate --target ja
i18nprune generate --resume --target jaWhen to use
- Create new target locale files from source keys.
- Fill only missing leaves for existing locales with
--resume. - Check provider pressure and generation coverage in CI with
--json.
Core behavior
generate reads extracted key observations and source leaves, then writes translated leaves for selected targets. In human mode, progress renders to stderr; in --json, quiet/silent, or non-TTY contexts, progress output is suppressed.
Key flags:
--target <code[,code]>target locale codes to process.--resumefill only missing/placeholder leaves.--allexpand to all configured target locales (commonly paired with--resume).--metadatawrite structured metadata leaves when metadata mode is enabled.--dry-runcompute output without writing locale files.
Metadata write behavior
generate always computes translation metadata during leaf processing. --metadata controls whether those structured leaves are persisted to locale JSON output.
If --metadata is not passed, output remains in plain string leaf mode unless your configured leaf mode is already structured.
Examples
# First-time generation for selected targets
i18nprune generate --target ja,fr
# Resume existing locales and preview writes
i18nprune generate --target ja --dry-run
# Top-up all configured locales without writing
i18nprune generate --resume --all --dry-runjq usage (--json)
generate --json keeps the standard envelope and emits GenerateJsonPayload in data.
Useful shape-aware paths:
.kind->"generate".data.targets[]requested targets.data.dynamicKeySites,.data.leavesProcessed.data.targetResults[]per-target status/counters/output- optional
.data.targetResults[].providerAttempts[]for fallback diagnostics
# Per-target status with write deltas
i18nprune generate --target ja,fr --dry-run --json \
| jq '.data.targetResults[] | {
target,
status,
partial,
sourceLeafCount,
resumeUpdatedLeafCount,
outputPath
}'
# Aggregate fallback pressure across targets
i18nprune generate --target ja --json \
| jq '[.data.targetResults[].fallbackCount // 0] | add'
# Surface failed targets only
i18nprune generate --target ja,fr --json \
| jq '.data.targetResults[] | select(.status != "ok") | {target, status, error: (.error // null)}'Suggested next steps
generate may emit [tip] lines when locale files contain keys outside the current code scan:
| Situation | Stable id | Typical command |
|---|---|---|
| Source locale has unused keys | suggest.cleanup.source_unused | i18nprune cleanup --dry-run |
| Target locale has extra keys | suggest.cleanup.target_extra | i18nprune cleanup --target <code> --dry-run |
Generate only translates keys referenced in the scan; unused source keys and target extras are left on disk until you run cleanup (source) or inspect targets manually.
Troubleshooting
- No writes in
--resumemode usually means targets are already fully populated. - Large
fallbackCountvalues indicate provider fallback pressure worth reviewing. - If JSON consumers break, verify they read from
.data.targetResults[]instead of parsing human stderr.