Documentation · Chapter 11

Organize translation catalogs.

Keys express meaning; catalogs provide language-specific wording. Stable keys let translators work without editing application classes.

Every lesson starts from the problem, explains the mechanism, then gives a concrete verification.

Use semantic keys

Use books.empty rather than sentence_17. A semantic key survives copy edits and tells a translator where the message belongs.

phpaml — zsh
{
  "i18n": {
    "enabled": true,
    "directory": "src/locales",
    "default": "en",
    "fallback": "en",
    "supported": ["en", "fr"],
    "detection": ["route", "cookie", "header"]
  }
}

Variables and plurals

Placeholders safely insert names. Plural catalogs use one and other so count controls the grammatical form.

Check catalog quality

i18n:check compares catalogs, i18n:missing fr lists missing keys, and malformed JSON fails visibly.