trans Modifier

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.

Hot Tip!

There's also a tag version that you may prefer.


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

return [
'bar' => 'Bar!',
'welcome' => 'Welcome, :name!',
'apples' => 'There is one apple|There are :count apples',
key: ''
this_many: 2
{{ key | trans }} or {{ "" | trans }}


Parameter replacements are only supported in the tag version.


To pluralize, use the trans_choice modifier with the count as the parameter. You can use a number or a variable.

{{ "foo.apples" | trans_choice(2) }}
{{ "foo.apples" | trans_choice($this_many) }}
There are 2 apples


As you can see above, you may use the modifier on inline strings. Instead of translation keys, you can use simple strings.
These will be referenced from resources/lang/fr.json (where fr is the locale).

"Hello": "Bonjour"
{{ "Hello" | trans }}
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →