What does "{{__ ('Login')}}" mean in the Laravel layout file?

2

In the file \resources\layouts\app.blade.php it has the following excerpt in line 37 :

{{ __('Login') }}

Apparently this is a Helper. But what is its meaning / function? I ask this because depending on the case I want to see if it is possible to implement implementations derived from it.

Laravel 5.6

    
asked by anonymous 07.03.2018 / 20:04

1 answer

4

The "helper" function __() of laravel translates the string or translation key according to the user's location, as reported in the official documentation . You can either pass them by setting up your location files:

Example:

resources / lang / en / messages.php:     

return [
    'welcome' => 'Seja bem-vindo a site!'
];

resources / lang / en / messages.php:     

return [
    'welcome' => 'Bienvenido al sitio!'
];

To display the translation snippet:

echo __('messages.welcome'); //se espanhol: 'Bienvenido al sitio!', se português: 'Seja bem-vindo ao site!'

You can also use literal strings to translate using .json files within the same directory:

resources / lang / es.json:

{
    "Eu amo programar.": "Me encanta programar."
}

To display:

echo __('Eu amo programar'); //se espanhol: 'Me encanta programar.'
    
07.03.2018 / 20:14