Skip to content

Instantly share code, notes, and snippets.

@quinhone
Created April 1, 2015 19:52
Show Gist options
  • Save quinhone/37c1bc41188168656881 to your computer and use it in GitHub Desktop.
Save quinhone/37c1bc41188168656881 to your computer and use it in GitHub Desktop.
//Nas rotas:
Route::get('empresa', array('before' => 'lang', 'as' => 'site_empresa', 'uses' => 'EmpresaController@getIndex'));
//No Filter:
Route::filter('lang', function()
{
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if(!Session::has('lang'))
{
switch ($lang){
case "pt":
return Session::put('lang', 'pt');
break;
case "en":
return Session::put('lang', 'en');
break;
case "es":
return Session::put('lang', 'es');
break;
default:
return Session::put('lang', 'pt');
break;
}
}
});
Route::filter('portugues', function()
{
Session::put('oglocale', 'pt_BR');
Session::put('lang', 'pt');
});
Route::filter('english', function()
{
Session::put('oglocale', 'en_US');
Session::put('lang', 'en');
});
Route::filter('espanol', function()
{
Session::put('oglocale', 'es_ES');
Session::put('lang', 'es');
});
//No Controller:
public function getIndex()
{
App::setLocale(Session::get('lang'));
return View::make('projetos.index_manejos', array());
}
//Na View:
@include('projetos.'.Session::get('lang').'.content_manejos')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment