So I need multiple languages on a site with urls like this:
mysite/en/language
mysite/it/language
mysite/es/language
I decided to go with the prefix in my routes like so:
$allLanguages = ["en", "it", "es"];
$lng = ( in_array( Request::segment(1), $allLanguages) ) ? Request::segment(1) : "";
Route::group(['prefix' => $lng ], function () {
Route::get('language', function () {
dd("The language is: " . Request::segment(1));
});
});
It works, but if I wanted to set up a default language and access url like so mysite/language - it wouldn't work.
What are your thoughts? Is this the best way how to handle multi language site? How to address the problem when accessing site without prefix ( show page with default language )?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1TCrIjz
via IFTTT
Aucun commentaire:
Enregistrer un commentaire