Based on this thread I tried to implement extra english language for my website, default is french and doesn't use any prefix so something like www.website.com
and switching to english would be www.website.com/en/
, I'd like to have the url for contact pages such as http://ift.tt/1CIWgsU
and http://ift.tt/1hD71BK
for english and french version respectively.
My current routes.php
if (Request::segment(1) == 'en') {
App::setLocale(Request::segment(1));
Config::set('app.locale_prefix', Request::segment(1));
}
else {
App::setLocale('fr');
Config::set('app.locale_prefix', '');
}
Route::group(array('prefix' => Config::get('app.locale_prefix')), function()
{
Route::get(
'/',
function () {
//return "main page - ".App::getLocale();
return view('index');
}
);
Route::get(
'/contact/',
function () {
return view('contact');
});
});
My header file where the flag icon to switch language is
@if (Lang::locale() == 'fr')
<a href=""><img src=""></a>
@elseif (strcasecmp(Request::segment(1), 'en') == 0 && Request::segment(2) != NULL)
<a href=""><img src=""></a>
@else
<a href=""><img src=""></a>
@endif
and the way I generate urls
<a class="block-title" href="">CONTACT</a>
I'd like to know a cleaner way to generate these and how I can get for english main page url to be www.website.com/en/
instead of www.website.com/en
Thanks a lot !
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire