Skip to content

Commit 853ce4a

Browse files
committed
Update detectors and stores overview
1 parent d6f447f commit 853ce4a

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

README.md

+17-15
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ Make sure to add it after `StartSession` and before `SubstituteBindings`:
4545
```php
4646
protected $middlewareGroups = [
4747
'web' => [
48-
\Illuminate\Session\Middleware\StartSession::class, // <= after this
4948
//...
5049
\CodeZero\Localizer\Middleware\SetLocale::class,
51-
\Illuminate\Routing\Middleware\SubstituteBindings::class, // <= before this
5250
],
5351
];
5452
```
@@ -110,16 +108,18 @@ Or you can use one or more custom domains for a locale:
110108

111109
By default, the middleware will use the following detectors to check for a supported locale in:
112110

113-
1. A custom route action
114-
2. The URL (domain or slug)
115-
3. A main omitted locale
116-
4. The authenticated user model
117-
5. The session
118-
6. A cookie
119-
7. The browser
120-
8. The app's default locale
111+
| # | Detector | Description |
112+
|:---:|-------------------------|------------------------------------------------------------------------|
113+
| 1. | `RouteActionDetector` | Checks for a locale in a custom route action. |
114+
| 2. | `UrlDetector` | Tries to find a locale based on the URL slugs or domain. |
115+
| 3. | `OmittedLocaleDetector` | Required if an omitted locale is configured. This will always be used. |
116+
| 4. | `UserDetector` | Checks a configurable `locale` attribute on the authenticated user. |
117+
| 5. | `SessionDetector` | Checks the session for a previously stored locale. |
118+
| 6. | `CookieDetector` | Checks a cookie for a previously stored locale. |
119+
| 7. | `BrowserDetector` | Checks the preferred language settings of the visitor's browser. |
120+
| 8. | `AppDetector` | Checks the default app locale as a last resort. |
121121

122-
Update the `detectors` array to choose which detectors to run and in what order.
122+
Update the `detectors` array in the config file to choose which detectors to run and in what order.
123123

124124
> You can create your own detector by implementing the `CodeZero\Localizer\Detectors\Detector` interface
125125
> and add a reference to it in the config file. The detectors are resolved from Laravel's IOC container,
@@ -129,11 +129,13 @@ Update the `detectors` array to choose which detectors to run and in what order.
129129

130130
The first supported locale that is returned by a detector will automatically be stored in:
131131

132-
- The session
133-
- A cookie
134-
- The app locale
132+
| # | Store | Description |
133+
|:---:|----------------|-------------------------------------------|
134+
| 1. | `SessionStore` | Stores the locale in the session. |
135+
| 2. | `CookieStore` | Stores the locale in a cookie. |
136+
| 3. | `AppStore` | Sets the locale as the active app locale. |
135137

136-
Update the `stores` array to choose which stores to use.
138+
Update the `stores` array in the config file to choose which stores to use.
137139

138140
> You can create your own store by implementing the `CodeZero\Localizer\Stores\Store` interface
139141
> and add a reference to it in the config file. The stores are resolved from Laravel's IOC container,

0 commit comments

Comments
 (0)