{trans 'cart.title'} looks the key up in the translation catalog of the request's locale and writes its text. A catalog is a flat JSON object in _lang/<locale>.json - _lang/en.json, _lang/nl.json. The catalogs are looked up from the page's directory up to the application root and then _common, the most specific winning; for a locale nl_NL the files nl_NL.json, nl-NL.json and nl.json all count. A key no catalog knows is written as the key itself, so a missing translation shows rather than disappearing.

The locale is $padLocale. With $padLocales listing several, a ?lang= value, the padLang cookie or the browser's Accept-Language picks among them.

Plurals and substitutions

A text with forms separated by | is plural: two forms are one and other, three are zero, one and other. count= picks the form and replaces %d in it. Every other name=value replaces :name in the text. The items are read raw, as {attrs} reads them, so a substitution may be called anything.

Escaping

The catalog's text is the application's own and is written as it stands, markup included. A substitution is data: it is written as {$x} writes a field, sanitized - and so is a key that no catalog knows. The trans pipe does the same for a value: {echo 'cart.title' | trans}. A {trans} without a key is a strict error.