I'm developing a project in laravel 5, but I would like it to be in several languages. Changing the language would be by clicking on the link for each language and automatically translating the site into that language. Thank you.
I'm developing a project in laravel 5, but I would like it to be in several languages. Changing the language would be by clicking on the link for each language and automatically translating the site into that language. Thank you.
Automatically translate will never be perfect, and php or laravel is not multilingual "databases" that interpret texts in different languages, they are programming language and framework respectively that run on the back-end >, who has to create the translation is you, using the programming.
However it is possible to do an automatic translation with Javascript and Google-translate (which is front-end ), but it's like I said "will not be perfect" > see an example in this answer:
However if you want to program, Laravel (examples pro 5.2) has Localization which is a way of designing multi-language sites, the folder structure:
/resources
/lang
/en
messages.php
/pt
messages.php
in / messages.php
<?php
return [
'welcome' => 'Welcome to our application'
];
en / messages.php
<?php
return [
'welcome' => 'Bem vindo a sua aplicação'
];
An example of Route:
Route::get('welcome/{locale}', function ($locale) {
App::setLocale($locale);
//
});
This will not translate the information that comes from the database, but the content of the layout and if you have a series of standard texts in the database it will be possible to translate them as long as it follows a unique pattern.
Documentation: link