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 | arrayorstring |
no default value |
| $fallback | stringornull |
null
|
| $locale | stringornull |
null
|
Return types
Closureorarrayorstringornull
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') ?>