v1.0.x-dev
1.0.9999999.9999999-dev
MIT
The Requires
- php >=7.1.3
- laravel/framework 5.6.*
by Serhii Yaniuk
Wallogit.com
2017 © Pedro Peláez
This package will no longer be maintained. It is very simple and does what it was created for, so I have no plans on supporting it in the future.
Very basic package that takes care of handling routing for multilanguage sites. Only basic features with minimum of configuration., (*1)
This package was developed using Laravel 5.6., (*2)
Use composer to install this package:, (*3)
composer require d3jn/laravel-languages
Laravel Package Auto-Discovery should handle adding service provider and alias for you automatically or you can manually add those to your providers and aliases list in app.php:, (*4)
'providers' => [
...
D3jn\LaravelLanguages\LanguagesServiceProvider::class,
...
],
...
'aliases' => [
...
'Languages' => D3jn\LaravelLanguages\Facades\Languages::class,
...
],
Lastly, you should publish it's configuration file:, (*5)
php artisan vendor:publish --provider="D3jn\LaravelLanguages\LanguagesServiceProvider"
Now you can proceed with configuring this package for your needs., (*6)
Open config/languages.php. All available configurations are well documented there., (*7)
Specify callable for properly setting locale in your routes file, for example:, (*8)
Languages::setLocaleCallable(function ($locale) {
// Example of initializing various packages with locale:
Carbon::setLocale($locale);
LaravelGettext::setLocale($locale);
App::setLocale(LaravelGettext::getLocaleLanguage());
});
Then define route group for your application routes and use Languages::init() as it's prefix and languages middleware:, (*9)
Route::group(
['prefix' => Languages::init(), 'middleware' => ['languages']],
function () {
Route::get('/', function () {
return __('hello');
});
...
}
);
This project is licensed under the MIT License - see the LICENSE.md file for details, (*10)
MIT