@@ -17,12 +17,12 @@ Automatically detect and set an app locale that matches your visitor's preferenc
1717- Uses the most common locale [ stores] ( #stores ) by default
1818- Easily create and add your own detectors and stores
1919
20- ## Requirements
20+ ## ✅ Requirements
2121
2222- PHP >= 7.1
2323- Laravel >= 5.6
2424
25- ## Install
25+ ## 📦 Install
2626
2727Install this package with Composer:
2828
@@ -32,7 +32,7 @@ composer require codezero/laravel-localizer
3232
3333Laravel will automatically register the ServiceProvider.
3434
35- ## Add Middleware
35+ ## 🧩 Add Middleware
3636
3737Add the middleware to the ` web ` middleware group in ` app/Http/Kernel.php ` .
3838Make sure to add it after ` StartSession ` and before ` SubstituteBindings ` :
@@ -65,7 +65,7 @@ protected $middlewarePriority = [
6565If you don't see the ` $middlewarePriority ` array in your kernel file,
6666then you can copy it over from the parent class ` Illuminate\Foundation\Http\Kernel ` .
6767
68- ## Configure
68+ ## ⚙️ Configure
6969
7070### Publish Configuration File
7171
@@ -101,7 +101,7 @@ Or you can use one or more custom domains for a locale:
101101];
102102```
103103
104- ### Configure Detectors (optional)
104+ ## 🔍 Detectors
105105
106106By default, the middleware will use the following detectors to check for a supported locale in:
107107
@@ -114,47 +114,118 @@ By default, the middleware will use the following detectors to check for a suppo
1141147 . The browser
1151158 . The app's default locale
116116
117- If you configure an omitted locale, no additional detectors will run after the ` OmittedLocaleDetector ` .
118- This makes sense, because the locale will always be determined by the URL in this scenario.
119-
120- You can configure the route action, session key, cookie name and the attribute on the user model that holds the locale.
121- By default this is all set to ` locale ` . If the user model does not have this attribute, it will skip this check.
122-
123- You can also choose which detectors to run and in what order.
117+ Update the ` detectors ` array to choose which detectors to run and in what order.
124118
125119> You can create your own detector by implementing the ` \CodeZero\Localizer\Detectors\Detector ` interface
126120> and add a reference to it in the config file. The detectors are resolved from Laravel's IOC container,
127121> so you can add any dependencies to your constructor.
128122
129- ### Configure Stores (optional)
123+ ## 💾 Stores
130124
131125The first supported locale that is returned by a detector will automatically be stored in:
132126
133127- The session
134128- A cookie
135129- The app locale
136130
137- In the configuration file, you can choose which stores to use.
131+ Update the ` stores ` array to choose which stores to use.
138132
139133> You can create your own store by implementing the ` \CodeZero\Localizer\Stores\Store ` interface
140134> and add a reference to it in the config file. The stores are resolved from Laravel's IOC container,
141135> so you can add any dependencies to your constructor.
142136
143- ## Testing
137+ ## 🛠️ More Configuration (optional)
138+
139+ ### ☑️ ` omit-locale `
140+
141+ If you don't want your main locale to have a slug, you can set it as the ` omit-locale ` (not the custom slug).
142+ If you do this, no additional detectors will run after the ` UrlDetector ` and ` OmittedLocaleDetector ` .
143+ This makes sense, because the locale will always be determined by those two in this scenario.
144+
145+ Example:
146+
147+ ``` php
148+ 'omit-locale' => 'en',
149+ ```
150+
151+ Result:
152+
153+ - /example-route (English without slug)
154+ - /nl/example-route (Other locales with slug)
155+
156+ Default: ` null `
157+
158+ ### ☑️ ` trusted-detectors `
159+
160+ Add any detector class name to this array to make it trusted. (do not remove it from the ` detectors ` array)
161+ When a trusted detector returns a locale, it will be used as the app locale, regardless if it's a supported locale or not.
162+
163+ Default: ` [] `
164+
165+ ### ☑️ ` url-segment `
166+
167+ The index of the URL segment that has the locale, when using the ` UrlDetector ` .
168+
169+ Default: ` 1 `
170+
171+ ### ☑️ ` route-action `
172+
173+ The custom route action that holds the locale, when using the ` RouteActionDetector ` .
174+
175+ Default: ` locale `
176+
177+ To use the custom route action ` locale ` , you register a route like this:
178+
179+ ``` php
180+ Route::group(['locale' => 'nl'], function () {
181+ //Route::get(...);
182+ });
183+ ```
184+
185+ ### ☑️ ` user-attribute `
186+
187+ The attribute on the user model that holds the locale, when using the ` UserDetector ` .
188+ If the user model does not have this attribute, this detector check will be skipped.
189+
190+ Default: ` locale `
191+
192+ ### ☑️ ` session-key `
193+
194+ The session key that holds the locale, when using the ` SessionDetector ` and ` SessionStore ` .
195+
196+ Default: ` locale `
197+
198+ ### ☑️ ` cookie-name `
199+
200+ The name of the cookie that holds the locale, when using the ` CookieDetector ` and ` CookieStore ` .
201+
202+ Default: ` locale `
203+
204+ ### ☑️ ` cookie-minutes `
205+
206+ The lifetime of the cookie that holds the locale, when using the ` CookieStore ` .
207+
208+ Default: ` 60 * 24 * 365 ` (1 year)
209+
210+ ## 🚧 Testing
144211
145212``` bash
146213composer test
147214```
215+ ## ☕️ Credits
216+
217+ - [ Ivan Vermeyen] ( https://github.com/ivanvermeyen )
218+ - [ All contributors] ( https://github.com/codezero-be/laravel-localizer/contributors )
148219
149- ## Security
220+ ## 🔒 Security
150221
151222If you discover any security related issues, please
[ e-mail me
] ( mailto:[email protected] ) instead of using the issue tracker.
152223
153- ## Changelog
224+ ## 📑 Changelog
154225
155226A complete list of all notable changes to this package can be found on the
156227[ releases page] ( https://github.com/codezero-be/laravel-localizer/releases ) .
157228
158- ## License
229+ ## 📜 License
159230
160231The MIT License (MIT). Please see [ License File] ( LICENSE.md ) for more information.
0 commit comments