Skip to content

Kirby 4.4.1

t()

Returns translate string for key from translation file

t(array|string $key, ?string $fallback = null, ?string $locale = null): Closure|array|string|null

Parameters

Name Type Default
$key * array|string
$fallback string|null null
$locale string|null null

Return type

Closure|array|string|null

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') ?>