check command is the core of glot. It scans your codebase for internationalization issues.
Usage
Check Types
You can run specific checks or all checks at once:| Type | Description |
|---|---|
hardcoded | Find untranslated text in JSX/TSX files |
missing | Identify translation keys used in code but missing from locale files |
orphan | Find unused translation keys defined in locale files |
Options
Directory to check. Defaults to current directory.
Enable verbose output for debugging.
Examples
Basic Check
Check the current directory for all i18n issues:Check Specific Directory
Check only thesrc directory:
Verbose Mode
Get detailed output including scanned files:Check Specific Issue Types
Run only hardcoded text detection:Output Format
Glot displays issues in a compiler-like format:Issue Severity
| Severity | Exit Code | Description |
|---|---|---|
| Error | 1 | Hardcoded text, missing keys |
| Warning | 0 | Orphan keys (unused translations) |
Understanding Issues
This section explains each issue type with examples and solutions.Hardcoded Text (hardcoded-text)
Hardcoded text is user-facing content that should be translated but isn’t using a translation function.
Example: JSX text content
Example: JSX text content
Problem code:Glot output:Solution:Then add the key to your locale file:
messages/en.json
Example: Input placeholder
Example: Input placeholder
Problem code:Glot output:Solution:
Example: Ternary expressions
Example: Ternary expressions
Problem code:Glot output:Solution:
How to fix hardcoded text
How to fix hardcoded text
Option 1: Use translation functions (Recommended)Replace hardcoded text with Option 2: Ignore specific text patternsAdd patterns to Option 3: Suppress with directiveUse Option 4: Customize checked attributesOnly check specific attributes in
t() calls:ignoreTexts in .glotrc.json:glot-disable-next-line for specific cases:.glotrc.json:For more details on detection rules and patterns, see Hardcoded Text Detection.
Missing Keys (missing-key)
Missing keys occur when your code references a translation key that doesn’t exist in your locale files.
Example: Using undefined key
Example: Using undefined key
Problem code:Locale file (missing the key):Glot output:Solution:Add the missing key to your locale file:
messages/en.json
messages/en.json
Example: Typo in key name
Example: Typo in key name
Problem code:Glot output:Solution:Fix the typo in your code:
How to fix missing keys
How to fix missing keys
Option 1: Add the key to locale files (Most common)Option 2: Fix typos in codeCheck for misspelled keys and correct them.Option 3: Handle dynamic keysFor dynamic keys that can’t be statically analyzed, declare them explicitly:Or use glob patterns:
messages/en.json
For more details on dynamic keys and namespace handling, see Missing Keys Detection.
Orphan Keys (orphan-key)
Orphan keys are translations defined in your locale files but never used in your code.
Example: Unused translation
Example: Unused translation
Locale file with unused key:Glot output:
messages/en.json
Example: Replica orphan (sync issue)
Example: Replica orphan (sync issue)
Primary locale (en.json):Non-primary locale with extra key:Glot output:
messages/en.json
messages/es.json
How to fix orphan keys
How to fix orphan keys
Option 1: Remove with Remove them:Option 2: Keep intentionallyIf you’re keeping keys for future use, you can:
glot clean (Recommended)Preview orphan keys:- Accept the warnings (they don’t fail builds)
- The
orphancheck is just informational
For more details on orphan key types and cleanup, see Orphan Keys Detection.
Exit Codes
| Code | Meaning |
|---|---|
| 0 | No errors found (warnings may exist) |
| 1 | Errors found |
Verbose Output
With-v flag, glot shows additional information: