shipglot

placeholder-mismatch

Missing, extra, renamed or reordered placeholders.

Default severity: error

What it checks

The translation must keep every placeholder of the source, with the same names, and add none: {name}, {{name}}, :name, %{name}, %1$s, %@, {0}, $t(key), @:key or XLIFF inline codes, depending on the format. A missing placeholder drops data from the message; an extra or renamed one renders as raw text or crashes the formatter. For printf-style formats, reordering %s and %d without positions (%1$s, %2$d) binds arguments to the wrong slots.

Example

An ICU argument renamed in translation. Config used for both runs:

{
  "sourceLocale": "en",
  "files": [
    {
      "format": "next-intl-json",
      "path": "messages/{locale}.json"
    }
  ]
}

Fails

messages/en.json

{
  "greeting": "Hello {name}, you have {count} new messages"
}

messages/fr.json

{
  "greeting": "Bonjour flagged by placeholder-mismatch: {nom}, vous avez {count} nouveaux messages"
}

Gate output

  • greeting
    placeholder mismatch: missing {name}; unexpected {nom}
    messages/fr.json:2

Passes

messages/en.json

{
  "greeting": "Hello {name}, you have {count} new messages"
}

messages/fr.json

{
  "greeting": "Bonjour {name}, vous avez {count} nouveaux messages"
}

Gate output

No placeholder-mismatch finding.

Change its severity

{
  "checks": {
    "placeholder-mismatch": "warning"
  }
}

Use "off" to disable it. To hide one finding, add "suppress": ["placeholder-mismatch:greeting"]; a suppress rule that stops matching is reported so it can be removed.

All checks