Skip to main content
Severity: Warning — does not affect exit code or fail CI builds.
Glot detects translation keys defined in the primary locale that are never referenced in your codebase.

Detection Rule

A key is flagged as unused if it:
  1. Exists in the primary locale file (e.g., messages/en.json)
  2. Is not referenced in any analyzed source file in your codebase
  3. Is not matched by any glot-message-keys annotation
This check helps identify dead translation keys that can be safely removed.
Supported .astro key usages and glot-message-keys declarations also count as references for unused-key detection.

What Gets Detected

Keys Not Used Anywhere

Keys that have no corresponding t() call in the codebase:
messages/en.json

Leftover Keys from Refactoring

Keys that were used but removed during code changes:
messages/en.json

Output Format

Severity

Warning - Unused keys don’t cause runtime errors, but they:
  • Increase bundle size (unused translations are shipped to users)
  • Make maintenance harder (more keys to manage)
  • Can confuse developers about which keys are actually used

How to Fix

Preview what will be removed:
Remove unused keys:
The clean command:
  • Removes unused keys from the primary locale
  • Automatically removes them from all replica locales too
  • Creates a backup before making changes

Option 2: Start Using the Key

If the key should be used, add it to your code:

Option 3: Keep Intentionally

If you’re keeping keys for future use:
  • Accept the warnings (they don’t fail builds)
  • Document why you’re keeping them (add comments)
  • Consider using feature flags to conditionally use them

Important Limitations

Dynamic Keys

If your code uses dynamic translation keys, glot cannot determine if a key is truly unused:
In this case, glot clean will refuse to run to prevent accidental deletion of keys that are actually used dynamically. Solution: Use glot-message-keys annotations to declare dynamic keys:
Or use glob patterns:
Then glot clean will know these keys are used and won’t remove them.

Conditional Usage

Keys used in conditional code might appear unused if that code path wasn’t analyzed:
Glot analyzes all code paths, so this will be detected correctly. However, if the key is in a separate file that’s not part of your configured sourceRoot, it won’t be detected.

Configuration

Source Root

Make sure your sourceRoot includes all files that might use translations:
.glotrc.json

Ignore Patterns

You can exclude specific directories from scanning:
.glotrc.json

Unused vs Orphan

Don’t confuse these two checks: Example:
messages/en.json (primary)
messages/zh.json (replica)
  • common.unused is flagged by unused (in primary but not used in code)
  • common.extra is flagged by orphan (in replica but not in primary)

Examples

Before cleanup:
messages/en.json
Code only uses:
After running glot clean --apply:
messages/en.json
All unused keys removed, keeping only what’s actually used.

Check Command

Run unused key detection

Clean Command

Remove unused keys automatically

Orphan Keys

Keys in replica locales not in primary

Directives

Declare dynamic keys with annotations