After searching through the documentation from laravel 4 I see that the way to set a language is to do
App::setLocale(\'en\');
But how do
This is a way:
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'));
There is great library for Laravel that allows you to handle locales flexible - mcamara laravel localization. In readme of the project you can find example how to implement such a switcher.