Types of Orphan Keys
Unused Keys
Keys that exist in locale files but are never referenced in code:messages/en.json
Replica Orphans
Keys that exist in non-primary locales but not in the primary locale. This typically happens when:- A key was deleted from the primary locale but not from other locales
- A key was accidentally added to a non-primary locale
messages/en.json (primary)
messages/es.json
Why This Matters
Orphan keys:- Increase translation file size unnecessarily
- Cause confusion for translators
- May indicate incomplete code cleanup
- Add maintenance burden
Severity
Orphan keys are reported as warnings (not errors) because:- They don’t break functionality
- They may be intentionally kept for future use
- Removal is optional
Running Orphan Detection
- npm
- pnpm
- yarn
- bun
bash npx glot check orphan Cleaning Up Orphan Keys
Use theclean command to remove orphan keys:
- npm
- pnpm
- yarn
- bun
Clean Only Specific Types
- npm
- pnpm
- yarn
- bun
Common Causes
Removed Features
A feature was removed but translations weren’t cleaned up:Refactored Keys
Keys were renamed but old ones weren’t removed:Copy-Paste Locales
Locale files copied from another project with unused keys.Keeping Keys Intentionally
If you want to keep certain keys without using them (e.g., for future features), you can:- Add a comment (though glot will still report them)
- Reference them in a special file that glot ignores
- Accept the warnings as informational