cvs: phpweb /include langchooser.inc
| From: | Gabor Hojtsy | Date: | Sat, 01 Mar 2003 13:52:46 +0000 |
| Subject: | cvs: phpweb /include langchooser.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-15967@lists.php.net to get a copy of this message | ||
goba Sat Mar 1 08:52:46 2003 EDT
Modified files:
/phpweb/include langchooser.inc
Log:
Applying KISS, taking account the user's Accept Language browser setting
(without bothering with the priority values provided by the UA, as those
are not applicable for us).
Index: phpweb/include/langchooser.inc
diff -u phpweb/include/langchooser.inc:1.4 phpweb/include/langchooser.inc:1.5
--- phpweb/include/langchooser.inc:1.4 Sun Feb 2 20:18:36 2003
+++ phpweb/include/langchooser.inc Sat Mar 1 08:52:46 2003
@@ -1,6 +1,6 @@
<?php // -*- C++ -*-
-// $Id: langchooser.inc,v 1.4 2003/02/03 01:18:36 cortesi Exp $
+// $Id: langchooser.inc,v 1.5 2003/03/01 13:52:46 goba Exp $
/*
@@ -30,9 +30,19 @@
if (preg_match("!^/manual/(\\w{2}(_\\w{2})?)(/|$)!", $_SERVER['REQUEST_URI'],
$flang)) {
language_add($flang[1]);
}
+unset($flang);
// USER PREFERENCE HANDLING SHOULD BE ADDED HERE IN THE FUTURE
+// Specified by the user via the browser's Accept Language setting
+// Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5"
+$browser_accept = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
+foreach ($browser_accept as $idx => $langcode) {
+ list($langcode) = @explode(";", trim($langcode));
+ language_add($langcode);
+}
+unset($browser_accept); unset($idx); unset($langcode);
+
// Language preferred by this mirror site
language_add(default_language());
@@ -64,9 +74,9 @@
// The Brazilian Portuguese code needs special attention
if ($langcode == 'pt_br') { $langcode = 'pt_BR'; }
- // Append language code in priority order
- // if it is not there already [try to lower number
- // of file_exists() calls to minumum]
+ // Append language code in priority order if it is not
+ // there already and supported by the PHP site. Try to
+ // lower number of file_exists() calls to the minumum...
if (!in_array($langcode, $LANGS) && isset($LANGUAGES[$langcode])) { $LANGS[] =
$langcode; }
}