Skip to main content
Severity: Error — causes exit code 1 and fails CI builds.
Glot detects when translation keys have different value types across locales (e.g., string in one locale, array in another), which causes runtime errors in next-intl.

Detection Rule

A key is flagged as type mismatch if:
  1. The key exists in both primary and replica locales
  2. The value type differs between locales:
    • String vs Object
    • String vs Array
    • Object vs Array
    • etc.
This check prevents runtime crashes caused by type inconsistencies.

What Gets Detected

String vs Array

The most common type mismatch:
messages/en.json (primary)
messages/zh.json (replica)
Runtime error:

Object vs String

Nested translations vs flat strings:
messages/en.json (primary)
messages/es.json (replica)
Runtime error:

Array vs Object

Arrays used as dictionaries vs objects:
messages/en.json (primary)
messages/fr.json (replica)

Output Format

The error indicates which locales have incompatible types.

Severity

Error - Type mismatches cause runtime crashes and must be fixed before deployment. They result in:
  • TypeError exceptions 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-array
messages/zh.json (before)
messages/zh.json (after)
Example: Fix string-to-object
messages/es.json (before)
messages/es.json (after)

Step 3: Verify

Run glot check again:
All type mismatch errors should be resolved.

Common Patterns

Plurals (Keep as Strings)

Don’t use arrays for plurals in next-intl:
All locales should use the same ICU format string.

Lists (Use Arrays)

Use arrays for fixed lists:
messages/en.json
messages/es.json
All locales must have arrays with the same length.

Nested Structures (Use Objects)

Use objects for nested namespaces:
messages/en.json
All locales must have the same object structure.

Prevention

1. Documentation

Document the expected type for each key:

2. Validation in CI

Run type-mismatch checks in CI to catch errors early:
Type mismatch checks exit with code 1, failing the build.

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

Code expecting array:
Primary locale (correct):
messages/en.json
Replica locale (wrong):
messages/fr.json
Runtime error:
Fix:
messages/fr.json
Code expecting object:
Primary locale (correct):
messages/en.json
Replica locale (wrong):
messages/de.json
Runtime error:
Fix:
messages/de.json

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