Make locale negotiator respect HTTP Accept-Language format

This commit is contained in:
Vojtěch Sajdl 2018-04-13 22:00:02 +02:00
parent 7f8c2408ca
commit 3980f5daa6
No known key found for this signature in database
GPG Key ID: 082BC82518E5F32E

View File

@ -253,7 +253,8 @@ class LocaleNegotiator
$langs = [];
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
$http_accept_language = str_replace("-", "_", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $http_accept_language, $lang_parse);
if (count($lang_parse[1])) {
$langs = array_combine($lang_parse[1], $lang_parse[4]);