You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,12 @@
11
11
12
12
Every browser has a setting for preferred website locales.
13
13
14
-
This can be read by PHP, usually with the `$_SERVER["HTTP_ACCEPT_LANGUAGE"]` variable. Its value is a string that looks like this: `nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4`.
14
+
This can be read by PHP, usually with the `$_SERVER["HTTP_ACCEPT_LANGUAGE"]` variable.
15
+
16
+
> `$_SERVER["HTTP_ACCEPT_LANGUAGE"]` will return a comma separated list of language codes. Each language code MAY have a "relative quality factor" attached ("nl;q=0.8") which determines the order of preference. For example: `nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4`. If no relative quality factor is present, the value is by default `1.0`.
17
+
18
+
**BrowserLocale** parses this string and lets you access the preferred locales quickly and easily.
15
19
16
-
`BrowserLocale` parses this string and lets you access the preferred locales quickly and easily.
17
20
18
21
## Requirements
19
22
@@ -51,7 +54,7 @@ This will return an instance of `\CodeZero\BrowserLocale\Locale` or `null` if no
51
54
52
55
```php
53
56
if ($locale !== null) {
54
-
$full = $locale->full; // Example: "en-US"
57
+
$full = $locale->locale; // Example: "en-US"
55
58
$language = $locale->language; // Example: "en"
56
59
$country = $locale->country; // Example: "US"
57
60
$weight = $locale->weight; // Example: 1.0
@@ -70,7 +73,7 @@ If no locales exist, an empty array will be returned.
70
73
71
74
```php
72
75
foreach ($locales as $locale) {
73
-
$full = $locale->full; // Example: "en-US"
76
+
$full = $locale->locale; // Example: "en-US"
74
77
$language = $locale->language; // Example: "en"
75
78
$country = $locale->country; // Example: "US"
76
79
$weight = $locale->weight; // Example: 1.0
@@ -82,7 +85,7 @@ foreach ($locales as $locale) {
82
85
You can get a flattened array, containing only specific locale info. These arrays will always be sorted by weight in descending order. There will be no duplicate values! (e.g. `en` and `en-US` are both the language `en`)
0 commit comments