Cannot switch language in Laravel 4 -
i tried routing switch language there's no change. me, pls?
route::get('lang/{lang}', function($lang) { app::setlocale($lang); return redirect::to('/'); });
app::setlocale()
not persistent - not remember between requests have stored. instead use session remember chosen locale, , read session locale on each request. can read default locale (from config) in case there isn't 1 set in session.
// app/routes.php route::get('lang/{lang}', function($lang) { session::put('my.locale', $lang); return redirect::to('/'); }); // app/start/global.php app::setlocale(session::get('my.locale', config::get('app.locale')));
Comments
Post a Comment