birdsolutions / laravel-language
Laravel Route Localization Package
1.1
2017-03-15 11:29 UTC
Requires (Dev)
- illuminate/support: ~5.1.0|~5.2.0|~5.3.0
- mockery/mockery: ^0.9.4
- orchestra/testbench: ^3.3
- phpunit/phpunit: 5.*
This package is auto-updated.
Last update: 2024-12-24 00:56:07 UTC
README
This package will help you localize your routes, set the language from the routes and add some nice functionality to it.
Installation
composer require birdsolutions/laravel-language
Service Provider Add the service provider to the config/app.php file
[
/*
* Package Service Providers...
*/
BirdSolutions\Language\Providers\LanguageServiceProvider::class,
]
Facade
'aliases' => [
...
'Language' => BirdSolutions\Language\Facades\Language::class,
]
Config Publish the configuration file.
php artisan vendor:publish --provider="BirdSolutions\Language\Providers\LanguageServiceProvider"
Middleware Add the language Middleware to the routeMiddleware array in kernel.php
protected $routeMiddleware = [
...
'language' => \BirdSolutions\Language\Middleware\LanguageMiddleware::class,
];
Routes
Route::group([
'prefix' => \Language::getLocale(),
'middleware' => 'language'
], function () {
// Add Localized routes here.
});
Change Language Manually
Route::any('/language', '\BirdSolutions\Language\Controllers\LanguageController@changeLanguage');
It will accept an input of language and set the language to the desired, you can send in get or post inputs.
<a href='/language?language=en'>English</a>