Package Data | |
---|---|
Maintainer Username: | codezero |
Maintainer Contact: | ivan@codezero.be (Ivan Vermeyen) |
Package Create Date: | 2018-04-01 |
Package Last Update: | 2024-03-11 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:13:37 |
Package Statistics | |
---|---|
Total Downloads: | 302,026 |
Monthly Downloads: | 4,726 |
Daily Downloads: | 32 |
Total Stars: | 46 |
Total Watchers: | 6 |
Total Forks: | 8 |
Total Open Issues: | 1 |
It's horrible to see what is happening now in Ukraine, as Russian army is bombarding houses, hospitals and kindergartens.
Please check out supportukrainenow.org for the ways how you can help people there. Spread the word.
And if you are from Russia and you are against this war, please express your protest in some way. I know you can get punished for this, but you are one of the hopes of those innocent people.
composer require codezero/laravel-localizer
Laravel will automatically register the ServiceProvider.
Add the middleware to the web
middleware group in app/Http/Kernel.php
, after StartSession
and before SubstituteBindings
:
protected $middlewareGroups = [
'web' => [
\Illuminate\Session\Middleware\StartSession::class, // <= after this
//...
\CodeZero\Localizer\Middleware\SetLocale::class,
//...
\Illuminate\Routing\Middleware\SubstituteBindings::class, // <= before this
],
];
In Laravel 6.x you also need to add the middleware to the $middlewarePriority
array in app/Http/Kernel.php
to trigger it in the correct order:
protected $middlewarePriority = [
\Illuminate\Session\Middleware\StartSession::class, // <= after this
//...
\CodeZero\Localizer\Middleware\SetLocale::class,
//...
\Illuminate\Routing\Middleware\SubstituteBindings::class, // <= before this
];
php artisan vendor:publish --provider="CodeZero\Localizer\LocalizerServiceProvider" --tag="config"
You will now find a localizer.php
file in the config
folder.
Add any locales you wish to support to your published config/localizer.php
file:
'supported-locales' => ['en', 'nl', 'fr'];
By default the middleware will use the following detectors to check for a supported locale in:
If you publish the configuration file, you can choose which detectors to run and in what order.
You can also create your own detector by implementing the \CodeZero\Localizer\Detectors\Detector
interface and add a reference to it in the config file. The detectors are resolved from Laravel's IOC container, so you can add any dependencies to your constructor.
The first supported locale that is returned by a detector will then be stored in:
If you publish the configuration file, you can choose which stores to use.
You can also create your own store by implementing the \CodeZero\Localizer\Stores\Store
interface and add a reference to it in the config file. The stores are resolved from Laravel's IOC container, so you can add any dependencies to your constructor.
composer test
If you discover any security related issues, please e-mail me instead of using the issue tracker.
A complete list of all notable changes to this package can be found on the releases page.
The MIT License (MIT). Please see License File for more information.