From: arno Date: Mon, 10 Aug 2009 19:56:30 +0000 (+0200) Subject: localization: do not consider regionalized accept languages X-Git-Tag: v0.3b_thomas~24 X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=commitdiff_plain;h=3181694edcb311144c22078ab6d59112bcde612a localization: do not consider regionalized accept languages --- diff --git a/inc/langutils.php b/inc/langutils.php index 8a81b9c..8d458fa 100644 --- a/inc/langutils.php +++ b/inc/langutils.php @@ -27,16 +27,16 @@ function parse_accept_language () { $accepts = explode (',', strtolower ($_SERVER ['HTTP_ACCEPT_LANGUAGE'])); foreach ($accepts as $acc) { - if (preg_match ('/^\s*([a-zA-Z-]+)\s*$/', $acc, $matches)) { + if (preg_match ('/^\s*([a-zA-Z]+)(-[a-zA-Z]+)?\s*$/', $acc, $matches)) { $possibilities [$matches [1]] = 1.0; } - if (preg_match ('/^\s*([a-zA-Z-]+)\s*;\s*q\s*=\s*([0-9\.]+)\s*$/', + if (preg_match ('/^\s*([a-zA-Z]+)(-[a-zA-Z]+)?\s*;\s*q\s*=\s*([0-9\.]+)\s*$/', $acc, $matches)) { - $val = floatval ($matches [2]); + $val = floatval ($matches [3]); if ($val > 1.0) { $val = 1.0; } - $possibilities [$matches [1]] = $val; + $possibilities [$matches [1]] = max ($val, $possibilities [$matches [1]]); } } arsort ($possibilities);