Hi,
i would like to create a bilingual website, let's say english and french:
http://www.domain.com/en/contact
http://www.domain.com/fr/contact
The site has some pages like contact, products, faq etc. and every page has it's own controller action.
First of all i redirect all / requests to /en:
Route::get('/', function(){Redirect::to('/en');});
After that i would use something like this:
Route::group(array('prefix' => 'en'), function()
Route::get('/contact', 'MyController@contact');
Route::get('/products', 'MyController@products');
Route::get('/faq', 'MyController@faq');
});
Route::group(array('prefix' => 'fr'), function()
Route::get('/contact', 'MyController@contact');
Route::get('/products', 'MyController@products');
Route::get('/faq', 'MyController@faq');
});
But that repeats my code and i don't really like it.
What about this one?
Route::get('/{language}/contact', 'MyController@contact');
Route::get('/{language}/products', 'MyController@products');
Route::get('/{language}/faq', 'MyController@faq');
Another idea would be this:
Route::get('/{language}/{page}', 'MyController');
But this don't lead directly to the actions but only the controller.
Any ideas?
Thanks, Sharping
You want to do multi-lang just for the interface or also the content? I think it's better to do something in views than separate your site by routing. You can set session variables that contains translated words for each languages to display in views.
Did you take a look at this: https://github.com/mcamara/laravel-localization ? I had the exact same problem as you and this package helped a lot!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community