Severity: Error — causes exit code 1 and fails CI builds.
Detection Rule
A key is flagged as type mismatch if:- The key exists in both primary and replica locales
- The value type differs between locales:
- String vs Object
- String vs Array
- Object vs Array
- etc.
What Gets Detected
String vs Array
The most common type mismatch:messages/en.json (primary)
messages/zh.json (replica)
Object vs String
Nested translations vs flat strings:messages/en.json (primary)
messages/es.json (replica)
Array vs Object
Arrays used as dictionaries vs objects:messages/en.json (primary)
messages/fr.json (replica)
Output Format
Severity
Error - Type mismatches cause runtime crashes and must be fixed before deployment. They result in:TypeErrorexceptions at runtime- Application crashes when accessing translations
- Broken user experience for affected locales
Why This Happens
1. Manual Translation Errors
Translators might not understand the data structure:2. Copy-Paste Mistakes
Copying from wrong part of the file:messages/en.json
messages/de.json
3. Incomplete Refactoring
Code changed from string to array but translations not updated:How to Fix
Step 1: Identify the Correct Type
Check how the key is used in your code:Step 2: Update All Replica Locales
Ensure all locales use the same type: Example: Fix string-to-arraymessages/zh.json (before)
messages/zh.json (after)
messages/es.json (before)
messages/es.json (after)
Step 3: Verify
Run glot check again:Common Patterns
Plurals (Keep as Strings)
Don’t use arrays for plurals in next-intl:Lists (Use Arrays)
Use arrays for fixed lists:messages/en.json
messages/es.json
Nested Structures (Use Objects)
Use objects for nested namespaces:messages/en.json
Prevention
1. Documentation
Document the expected type for each key:2. Validation in CI
Run type-mismatch checks in CI to catch errors early:3. Translation Guidelines
Provide translators with:- Clear examples of data structures
- Instructions to preserve JSON structure
- Tools to validate JSON syntax
4. Translation Management Systems
Use TMS tools that:- Preserve JSON structure automatically
- Validate translations before export
- Provide visual editors for complex structures
Examples
Array Type Mismatch
Array Type Mismatch
Code expecting array:Primary locale (correct):Replica locale (wrong):Runtime error:Fix:
messages/en.json
messages/fr.json
messages/fr.json
Object Type Mismatch
Object Type Mismatch
Code expecting object:Primary locale (correct):Replica locale (wrong):Runtime error:Fix:
messages/en.json
messages/de.json
messages/de.json
Related
Check Command
Run type mismatch detection
Configuration
Configure locales and paths
Replica Lag
Missing keys in replica locales
Missing Keys
Keys used but not defined