Skip to content

Commit 8b320e4

Browse files
authored
Review and update README and LICENSE (#8)
1 parent c2da093 commit 8b320e4

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
Copyright (c) 2018 Ivan Vermeyen (<[email protected]>)
3+
Copyright (c) Ivan Vermeyen ([email protected])
44

55
> Permission is hereby granted, free of charge, to any person obtaining a copy
66
> of this software and associated documentation files (the "Software"), to deal

README.md

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
# Laravel Localizer
22

3-
## IMPORTANT: March 2022
4-
5-
[![Support Ukraine](https://raw.githubusercontent.com/hampusborgos/country-flags/main/png100px/ua.png)](https://github.com/hampusborgos/country-flags/blob/main/png100px/ua.png)
6-
7-
It's horrible to see what is happening now in Ukraine, as Russian army is
8-
[bombarding houses, hospitals and kindergartens](https://twitter.com/DavidCornDC/status/1501620037785997316).
9-
10-
Please [check out supportukrainenow.org](https://supportukrainenow.org/) for the ways how you can help people there.
11-
Spread the word.
12-
13-
And if you are from Russia and you are against this war, please express your protest in some way.
14-
I know you can get punished for this, but you are one of the hopes of those innocent people.
15-
16-
---
17-
183
[![GitHub release](https://img.shields.io/github/release/codezero-be/laravel-localizer.svg?style=flat-square)](https://github.com/codezero-be/laravel-localizer/releases)
194
[![Laravel](https://img.shields.io/badge/laravel-10-red?style=flat-square&logo=laravel&logoColor=white)](https://laravel.com)
205
[![License](https://img.shields.io/packagist/l/codezero/laravel-localizer.svg?style=flat-square)](LICENSE.md)
@@ -25,7 +10,7 @@ I know you can get punished for this, but you are one of the hopes of those inno
2510

2611
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R3UQ8V)
2712

28-
#### Automatically detect and set an app locale that matches your visitor's preference.
13+
Automatically detect and set an app locale that matches your visitor's preference.
2914

3015
- Define your supported locales and match your visitor's preference
3116
- Uses the most common locale [detectors](#detectors) by default
@@ -39,15 +24,18 @@ I know you can get punished for this, but you are one of the hopes of those inno
3924

4025
## Install
4126

27+
Install this package with Composer:
28+
4229
```bash
4330
composer require codezero/laravel-localizer
4431
```
4532

4633
Laravel will automatically register the ServiceProvider.
4734

48-
#### Add Middleware
35+
## Add Middleware
4936

50-
Add the middleware to the `web` middleware group in `app/Http/Kernel.php`, after `StartSession` and before `SubstituteBindings`:
37+
Add the middleware to the `web` middleware group in `app/Http/Kernel.php`.
38+
Make sure to add it after `StartSession` and before `SubstituteBindings`:
5139

5240
```php
5341
protected $middlewareGroups = [
@@ -61,7 +49,8 @@ protected $middlewareGroups = [
6149
];
6250
```
6351

64-
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:
52+
In Laravel 6.x and higher, you also need to add the middleware to the `$middlewarePriority` array in `app/Http/Kernel.php`
53+
to trigger it in the correct order:
6554

6655
```php
6756
protected $middlewarePriority = [
@@ -73,53 +62,64 @@ protected $middlewarePriority = [
7362
];
7463
```
7564

76-
#### Publish Configuration File
65+
If you don't see the `$middlewarePriority` array in your kernel file,
66+
then you can copy it over from the parent class `Illuminate\Foundation\Http\Kernel`.
67+
68+
## Configure
69+
70+
### Publish Configuration File
7771

7872
```bash
7973
php artisan vendor:publish --provider="CodeZero\Localizer\LocalizerServiceProvider" --tag="config"
8074
```
8175

8276
You will now find a `localizer.php` file in the `config` folder.
8377

84-
#### Configure Supported Locales
78+
### Configure Supported Locales
8579

8680
Add any locales you wish to support to your published `config/localizer.php` file:
8781

8882
```php
8983
'supported-locales' => ['en', 'nl', 'fr'];
9084
```
9185

92-
## Drivers
93-
94-
#### Detectors
86+
### Configure Detectors
9587

96-
By default the middleware will use the following detectors to check for a supported locale in:
88+
By default, the middleware will use the following detectors to check for a supported locale in:
9789

9890
1. The URL slug
91+
2. The authenticated user model
9992
2. The session
10093
3. A cookie
10194
4. The browser
10295
5. The app's default locale
10396

104-
If you publish the configuration file, you can choose which detectors to run and in what order.
97+
You can configure the session key, cookie name and the attribute on the user model that holds the locale.
98+
By default this is all set to `locale`. If the user model does not have this attribute, it will skip this check.
10599

106-
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.
100+
You can also choose which detectors to run and in what order.
107101

108-
#### Stores
102+
> You can create your own detector by implementing the `\CodeZero\Localizer\Detectors\Detector` interface
103+
> and add a reference to it in the config file. The detectors are resolved from Laravel's IOC container,
104+
> so you can add any dependencies to your constructor.
109105
110-
The first supported locale that is returned by a detector will then be stored in:
106+
### Configure Stores
107+
108+
The first supported locale that is returned by a detector will automatically be stored in:
111109

112110
- The session
113111
- A cookie
114112
- The app locale
115113

116-
If you publish the configuration file, you can choose which stores to use.
114+
In the configuration file, you can choose which stores to use.
117115

118-
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.
116+
> You can create your own store by implementing the `\CodeZero\Localizer\Stores\Store` interface
117+
> and add a reference to it in the config file. The stores are resolved from Laravel's IOC container,
118+
> so you can add any dependencies to your constructor.
119119
120120
## Testing
121121

122-
```
122+
```bash
123123
composer test
124124
```
125125

0 commit comments

Comments
 (0)