How to transform text with translation variables in Laravel

Categorized as Laravel Tagged

Hello, friends! You may be don’t know yet, but actually you can make some text transformations (uppercase, lowercase, capitalization) on your translation variables in Laravel. Here is the code:

{{ __('messages.hello', ['name' => 'daniel']) }}

// resources/lang/messages.php
'hello' => 'Hi, :Name'
// "Hi, Daniel"

'hello' => 'Hi, :NAME'
// "Hi, DANIEL"

'hello' => 'Hi, :name'
// "Hi, daniel"

Leave a reply

Your email address will not be published. Required fields are marked *