Skip to content

Commit 41d17d8

Browse files
authored
Merge pull request #7 from fgagne/Update-README.md
Update readme.md
2 parents cd009ed + 9d31940 commit 41d17d8

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

README.md

+21-17
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ make the value available to the rest of your application. Its callback hook
1010
offers a convenient way to initialize other libraries or execute code based on
1111
the locale value.
1212

13+
## Installation
14+
15+
composer require boronczyk/localization-middleware
16+
1317
## Basic Example
1418

1519
use Boronczyk\LocalizationMiddleware;
@@ -33,10 +37,10 @@ the locale value.
3337
$middleware = new LocalizationMiddleware($availableLocales, $defaultLocale);
3438

3539
$middleware->setSearchOrder([
36-
LocationMiddleware::FROM_URI_PATH,
37-
LocationMiddleware::FROM_URI_PARAM,
38-
LocationMiddleware::FROM_COOKIE,
39-
LocationMiddleware::FROM_HEADER
40+
LocalizationMiddleware::FROM_URI_PATH,
41+
LocalizationMiddleware::FROM_URI_PARAM,
42+
LocalizationMiddleware::FROM_COOKIE,
43+
LocalizationMiddleware::FROM_HEADER
4044
]);
4145
$middleware->setCallback(function (string $locale) {
4246
putenv("LANG=$locale");
@@ -78,36 +82,36 @@ methods:
7882
Sets the order in which inputs are searched for a suitable locale.
7983

8084
$middleware->setSearchOrder([
81-
LocationMiddleware::FROM_URI_PATH,
82-
LocationMiddleware::FROM_URI_PARAM,
83-
LocationMiddleware::FROM_COOKIE,
84-
LocationMiddleware::FROM_HEADER
85+
LocalizationMiddleware::FROM_URI_PATH,
86+
LocalizationMiddleware::FROM_URI_PARAM,
87+
LocalizationMiddleware::FROM_COOKIE,
88+
LocalizationMiddleware::FROM_HEADER
8589
]);
8690

8791
Adding or removing locale sources from the order modifies the search
8892
domain.
8993

9094
// only search cookies and the Accept-Language header
9195
$middleware->setSearchOrder([
92-
LocationMiddleware::FROM_COOKIE,
93-
LocationMiddleware::FROM_HEADER
96+
LocalizationMiddleware::FROM_COOKIE,
97+
LocalizationMiddleware::FROM_HEADER
9498
]);
9599

96100
The available local source constants are:
97101

98-
* `LocationMiddleware::FROM_URI_PATH`
102+
* `LocalizationMiddleware::FROM_URI_PATH`
99103
Search for the locale in the URI path. The first directory value in
100-
the request path is considered the locale, for example
104+
the request path is considered the locale, for example
101105
`https://example.com/en_US/foo`.
102106

103-
* `LocationMiddleware::FROM_URI_PARAM`
107+
* `LocalizationMiddleware::FROM_URI_PARAM`
104108
Search for the locale in the URI parameter (the default parameter name
105109
is `locale`).
106110

107-
* `LocationMiddleware::FROM_COOKIE`
111+
* `LocalizationMiddleware::FROM_COOKIE`
108112
Search for the locale in cookies (the default cookie name is `locale`).
109113

110-
* `LocationMiddleware::FROM_HEADER`
114+
* `LocalizationMiddleware::FROM_HEADER`
111115
Search for the local in the HTTP `Accept-Language` header. Header
112116
searches make a best-effort search for locales, languages, and possible
113117
quality modifiers.
@@ -153,7 +157,7 @@ methods:
153157

154158
* `setCallback(callable $func)`
155159
Sets a callback that is invoked after the middleware identifies the locale,
156-
offering the developer a chance to conveniently initialize other libraries
160+
offering the developer a chance to conveniently initialize other libraries
157161
or execute other code with the value. The callable’s signature is:
158162
`function (string $locale)`.
159163

@@ -167,4 +171,4 @@ methods:
167171

168172

169173
## License
170-
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.heygears.com%2Ftboronczyk%2Flocalization-middleware.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.heygears.com%2Ftboronczyk%2Flocalization-middleware?ref=badge_large)
174+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.heygears.com%2Ftboronczyk%2Flocalization-middleware.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.heygears.com%2Ftboronczyk%2Flocalization-middleware?ref=badge_large)

0 commit comments

Comments
 (0)