X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=inc%2Flangutils.php;h=8d458fa53e08c21be76a89803d845c14ca30ab81;hp=5ac4a3766c0ed44b7b18d62dc8294db8d2b8401f;hb=19730f2e2bbf61f389882c646f58349df3bcd848;hpb=0feade23ffa41ac299b252a93be4da11bc2a16b7 diff --git a/inc/langutils.php b/inc/langutils.php index 5ac4a37..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); @@ -55,7 +55,7 @@ function other_languages ($current_lang) { if ($dotpos !== false) { $script = substr ($script, 0, $dotpos); } - + global $translations; $links = Array (); foreach ($translations as $lang => $obj) {