Skip to content

Commit ec0634b

Browse files
committed
Update README
1 parent 8126927 commit ec0634b

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

README.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,43 @@
2121

2222
## Install
2323

24-
```php
24+
```bash
2525
composer require codezero/laravel-localizer
2626
```
2727

2828
Laravel 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
3535
protected $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
4861
php 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
6881
2. The session
6982
3. A cookie
7083
4. The browser

0 commit comments

Comments
 (0)