2121
2222## Install
2323
24- ``` php
24+ ``` bash
2525composer require codezero/laravel-localizer
2626```
2727
2828Laravel will automatically register the ServiceProvider.
2929
3030#### Add Middleware
3131
32- Add the middleware to the ` web ` middleware group in ` app/Http/Kernel.php ` after ` StartSession ` :
32+ Add the middleware to the ` web ` middleware group in ` app/Http/Kernel.php ` , after ` StartSession ` and before ` SubstituteBindings ` :
3333
3434``` php
3535protected $middlewareGroups = [
3636 'web' => [
37- //...
38- \Illuminate\Session\Middleware\StartSession::class,
37+ \Illuminate\Session\Middleware\StartSession::class, // <= after this
3938 //...
4039 \CodeZero\Localizer\Middleware\SetLocale::class,
40+ //...
41+ \Illuminate\Routing\Middleware\SubstituteBindings::class, // <= before this
4142 ],
4243];
4344```
4445
45- #### Publish Configuration File
46+ 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:
4647
4748``` php
49+ protected $middlewarePriority = [
50+ \Illuminate\Session\Middleware\StartSession::class, // <= after this
51+ //...
52+ \CodeZero\Localizer\Middleware\SetLocale::class,
53+ //...
54+ \Illuminate\Routing\Middleware\SubstituteBindings::class, // <= before this
55+ ];
56+ ```
57+
58+ #### Publish Configuration File
59+
60+ ``` bash
4861php artisan vendor:publish --provider=" CodeZero\Localizer\LocalizerServiceProvider" --tag=" config"
4962```
5063
@@ -62,9 +75,9 @@ Add any locales you wish to support to your published `config/localizer.php` fil
6275
6376#### Detectors
6477
65- By default the middleware will use the following detectors for a supported locale:
78+ By default the middleware will use the following detectors to check for a supported locale in :
6679
67- 1 . The URL
80+ 1 . The URL slug
68812 . The session
69823 . A cookie
70834 . The browser
0 commit comments