I'm trying to learn how to develop my website using Laravel 5.
Now i'm working on the languages of the site, but I have some questions that I hope you guys might know how to solve.
I know that the Location service helps a lot when translating the site, but I want something a little more complicated. I want to put a <select></select>
tag at the top of my header where the user will have the option to change to another language.
Right now, I have already created the following folders that will have all the information to be translated.
-resources
-lang
-en
messages.php
-es
messages.php
Each messages.php file has the complete directory of the information to be translated.
I know how to do this using pure php ($_SESSION) and jQuery, but I have no idea how to do this with laravel.
I would like that the website has will look like this:
/[about]
/[contact]
/en
/en/[about]
/en/[contact]
/fr
/fr/[about]
/fr/[contact]
Hope you guys help. Thanks.
EDIT
I just found a laravel package which can help to manage this kind specific issue in the proper way.
The package name is Laravel Localization and it's pretty easy to use.
Use the directions from here: http://laravel.com/docs/master/localization
Route::get('{locale}/{page?}', function ($locale, $page == '') {
App::setLocale($locale);
// your code
});
And as for the change of the language from a drop down, just redirect the users based on their choice with java script.