tt()
Translate by key and then replace placeholders in the text
tt(string $key, string $fallback = null, array $replace = null, string $locale = null): string
Parameters
Name | Type | Default |
---|---|---|
$key * | string |
– |
$fallback | string |
null |
$replace | array |
null |
$locale | string |
null |
Return type
string
Example:
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']) ?>