Skip to content

Kirby 5.0.4

tt()

Translate by key and then replace placeholders in the text

tt(string $key, array|string|null $fallback = null, array|null $replace = null, string|null $locale = null): string

Parameters

Name Type Default
$keyrequired string no default value
$fallback arrayorstringornull null
$replace arrayornull null
$locale stringornull null

Return type

string

Examples

/site/languages/en.php
return [
  'code' => 'en',
  'default' => false,
  'direction' => 'ltr',
  'locale' => 'en_US',
  'name' => 'English',
  'translations' => [
    'alert' => 'Attention: { message }'
  ]
];

In your templates…

<?= tt('alert', ['message' => 'Something is not right']) ?>