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.'