t()
Returns translate string for key from translation file
t(array|string $key, string|null $fallback = null, string|null $locale = null): Closure|array|string|null
Parameters
Name | Type | Default |
---|---|---|
$keyrequired | array orstring |
no default value |
$fallback | string ornull |
null
|
$locale | string ornull |
null
|
Return types
Closure
orarray
orstring
ornull
Examples
The t()
helper returns a predefined translation string by key.
Translations can be defined in the language files or in plugins.
Get a translation string by key:
<?= t('confirm') ?>
Use a fallback value if no translation exists:
<?= t('confirm', 'Confirm') ?>
Force a particular locale:
<?= t('confirm', 'Bestätigen', 'de') ?>