Laravel Route Localization Package
This package will help you localize your routes, set the language from the routes and add some nice functionality to it., (*1)
Installation, (*2)
composer require birdsolutions/laravel-language, (*3)
Service Provider
Add the service provider to the config/app.php file, (*4)
```$xslt
[
/*
* Package Service Providers...
*/
BirdSolutions\Language\Providers\LanguageServiceProvider::class,
], (*5)
**Facade**
```$xslt
'aliases' => [
...
'Language' => BirdSolutions\Language\Facades\Language::class,
]
Config
Publish the configuration file., (*6)
php artisan vendor:publish --provider="BirdSolutions\Language\Providers\LanguageServiceProvider"
Middleware
Add the language Middleware to the routeMiddleware array in kernel.php, (*7)
```$xslt
protected $routeMiddleware = [
...
'language' => \BirdSolutions\Language\Middleware\LanguageMiddleware::class,
];, (*8)
**Routes**
```$xslt
Route::group([
'prefix' => \Language::getLocale(),
'middleware' => 'language'
], function () {
// Add Localized routes here.
});
Change Language Manually
```$xslt
Route::any('/language', '\BirdSolutions\Language\Controllers\LanguageController@changeLanguage');, (*9)
It will accept an input of language and set the language to the desired, you can send in get or post inputs.
```$xslt
<a href='/language?language=en'>English</a>