dev-master
9999999-devMultilingual routes and language switcher for laravel 5
MIT
The Requires
- php >=5.6.4
- laravel/framework 5.3.*
by Andrey Yaresko
laravel language languages multilingual
Wallogit.com
2017 © Pedro Peláez
Multilingual routes and language switcher for laravel 5
Multilingual routes and language switcher for laravel 5, (*1)
The preferred way to install extension is via composer. Check the composer.json for this extension's requirements and dependencies., (*2)
To install, either run, (*3)
$ php composer.phar require aayaresko/laravel-language "*"
or add, (*4)
"aayaresko/laravel-language": "*"
to the require section of your composer.json., (*5)
After installing the Socialite library, register the aayaresko\language\ServiceProvider in your config/app.php configuration file:, (*6)
'providers' => [
// Other service providers...
aayaresko\language\ServiceProvider::class,
],
Also, add the Language facade to the aliases array in your app configuration file:, (*7)
'Language' => aayaresko\language\LanguageFacade::class,
Use Language::getLocale() method to add language prefix to your routes:, (*8)
Route::group(['prefix' => Language::getLocale()], function () {
Route::get('/home', function () {
return view('frontend.index');
})->name('home');
});
Use Language::renderDropdownList() in your view-file to generate language dropdown list (note a exclamation marks):, (*9)
{!! Language::renderDropdownList() !!}
This method takes 'locales' array which specified in you app.config file. It assumes that each 'locale' item key is a language 'code' and value is a 'visible_name'.
You can control language item label content via Language::renderDropdownList() $label_template value:, (*10)
{!! Language::renderDropdownList('{visible_name} ({code})') !!}
Label will look like this: 'English (en)'
You can add additional items to any 'locale' item value and render that value in Language::renderDropdownList().
For example, if you added 'description' and your app.config looks something like this:, (*11)
'locales' => [
'en' => [
'visible_name' => 'English',
'description' => 'Some simple text'
],
'ru' => 'Русский',
]
You can render 'description' item:, (*12)
{!! Language::renderDropdownList('{visible_name} ({code}) {description}') !!}
Label will look like this: 'English (en) Some simple text', (*13)
You can customize html of language dropdown list.
Simply run php ./artisan vendor:publish --tag=language and edit dropdown.blade.php template in your resources/views/vendor/language directory., (*14)
Multilingual routes and language switcher for laravel 5
MIT
laravel language languages multilingual