Translate

Translates a string


This tag will retrieve a string from a language file in the current locale. It is the equivalent of the trans and trans_choice methods provided by Laravel.

Usage

Get the bar string from the site/lang/en/foo.php translation file (where en is the current locale).

<?php
return [
    'bar' => 'Bar!',
    'welcome' => 'Welcome, :name!',
    'apples' => 'There is one apple|There are many apples',
];
{{ trans:foo.bar }} or {{ trans key="foo.bar" }}
Bar! or Bar!

Parameters

Any additional tag parameters will be treated as parameters that should be replaced in the string.

{{ trans:foo.welcome name="Bob" }}
Welcome, Bob!

Pluralization

To pluralize, use the trans_choice tag with a count parameter.

{{ trans_choice:foo.apples count="2" }}
There are many apples.

Parameters

key

tagpart|string

The key of the translation string to find. Include both the filename and string key delimited with dots. Can be used as a tag part or a key parameter.

any parameters

string

Any additional parameters will be treated as parameters that should be replaced in the string.

count

integer 1

When using trans_choice, this is the number that defines the pluralization.

Last modified on October 18, 2017