What Are Missing Keys?
A missing key occurs when:- Your code calls a translation function with a key:
t('common.submit') - That key doesn’t exist in your locale JSON files
- A developer adds a translation call but forgets to add the key to locale files
- A key is misspelled in the code
- Keys are deleted from locale files but still used in code
Example
Code using a translation:messages/en.json
Detection Methods
Glot identifies translation usage through:Direct Function Calls
Template Literals (Warning)
Dynamic keys can’t be statically analyzed:Supported Translation Hooks
Glot recognizes these next-intl translation functions:| Function | Context | Import |
|---|---|---|
useTranslations | Client components | next-intl |
getTranslations | Server components | next-intl/server |
Custom translation functions or renamed imports are not automatically
detected. If you use a wrapper function, consider using
glot-message-keys to declare keys.
Severity
Missing keys are reported as errors because they cause runtime issues:- In development: Often shows the key itself or an error message
- In production: Can break the user experience
Fixing Missing Keys
1
Run Check
- npm
- pnpm
- yarn
- bun
2
Review Issues
Check each missing key report to understand what’s needed.
3
Add Keys
Add the missing keys to your locale files:
messages/en.json
4
Verify
Run the check again to confirm all keys are present:
- npm
- pnpm
- yarn
- bun
Dynamic Keys
When glot encounters dynamic keys, it issues a warning:Handling Dynamic Keys
Options for handling dynamic keys:-
Refactor to static keys (recommended):
-
Declare expected keys (when refactoring is not feasible):
Or use a glob pattern to match multiple keys:
-
Suppress the warning (last resort):
Option 2 (
glot-message-keys) is preferred over option 3 because it
explicitly declares which keys are used, enabling accurate tracking for the
clean command.Primary vs Non-Primary Locales
Missing key detection checks against the primary locale defined in your config:.glotrc.json
messages/en.json, it’s reported as a missing key.
If a key exists in en.json but not in es.json, it’s reported as replica lag (a different check).