Set locale in Laravel

Create a route for your language selector:

Route::get('language/{lang}', 
           array(
                  'as' => 'language.select', 
                  'uses' => 'LanguageController@select'
                 )
          );

Create your language selectors links in Laravel Blade’s view:

<html><body>

    Please select a Language:

    {{link_to_route('language.select', 'English', array('en'))}}

    {{link_to_route('language.select', 'Portuguese', array('pt'))}}

</body></html>

A Controller:

Class LanguageController extends BaseController {

    public function select($lang)
    {
        Session::put('lang', $lang);

        return Redirect::route('home');
    }

}

Then in your app/start/global.php you can:

App::setLocale(Session::get('lang', 'en'));

source: http://stackoverflow.com/questions/20273956/set-locale-on-the-fly-in-laravel4

B logbook : PHP | Javascript | Laravel | CodeIgniter | VueJs | ReactJs | WordPress