Skip to content

Dynamic key handling ​

Dynamic keys are translation calls where the first argument is not a static string literal.

Why this is a hard boundary ​

Static analysis cannot safely resolve runtime expressions like t(user.role + ".label") or t(`prefix.${id}`). Guessing these keys would create false deletions and broken locale files.

What i18nprune does ​

  • Detects and reports dynamic call sites.
  • Preserves dynamic reporting as warnings (not direct validate failures).
  • Reuses per-file const-map where safe so rebuildable template keys are treated as static keys.
  • Surfaces dynamic counts in command JSON payloads for CI visibility.
  • When a mixed template has a static prefix (for example t(`app.nav.${id}`) → app.nav), lists locale-inferred candidate keys from the source locale under that prefix. Candidates are hints only — they are never treated as proven keys and never deleted by cleanup without an explicit policy change.

Operational guidance ​

  • Prefer literal keys for high-confidence validate/sync/cleanup behavior.
  • Use dynamic reports as an audit checklist.
  • In CI/non-interactive mode, dynamic sites are emitted as data (no prompts).

Where to use this ​