Wallogit.com
2017 © Pedro Peláez
A package for Laravel 4 which sets dynamic the Language for the user, (*1)
If you have any suggestions or improvements feel free to create an issue or create a Pull Request., (*3)
Add jones/language-selector as a requirement to composer.json:, (*4)
{
...
"require": {
...
"jones/language-selector": "dev-master"
...
},
}
Update composer:, (*5)
$ php composer.phar update
Add the provider to your app/config/app.php:, (*6)
'providers' => array(
...
'Jones\LanguageSelector\LanguageSelectorServiceProvider',
),
(Optional) Publish package config:, (*7)
$ php artisan config:publish jones/language-selector
lang_key: The key where the language of the user is setFirst it is checked whether you entered a language key and if so we try to get the language from the user (You need to use Laravel's Auth class or Sentry and the language have to be the short key, eg 'en'). If we found a valid language we use this. Second we check the "Accept-Language" Header and try to set the language with it. If both failed we use the locale set in the config., (*8)