cvs: phpweb /include langchooser.inc

From: Date: Sat, 15 Mar 2003 12:56:28 +0000
Subject: cvs: phpweb /include langchooser.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-16369@lists.php.net to get a copy of this message
goba Sat Mar 15 07:56:28 2003 EDT Modified files: /phpweb/include langchooser.inc Log: Really remember last used language :) And do not override the user setting with it. What if I would like to see the Hungarian version of a page on time, and I still want to use English as my default language ;) Index: phpweb/include/langchooser.inc diff -u phpweb/include/langchooser.inc:1.18 phpweb/include/langchooser.inc:1.19 --- phpweb/include/langchooser.inc:1.18 Fri Mar 14 04:40:32 2003 +++ phpweb/include/langchooser.inc Sat Mar 15 07:56:28 2003 @@ -1,6 +1,6 @@ <?php // -*- C++ -*- -// $Id: langchooser.inc,v 1.18 2003/03/14 09:40:32 derick Exp $ +// $Id: langchooser.inc,v 1.19 2003/03/15 12:56:28 goba Exp $ /* @@ -56,7 +56,7 @@ $explicitly_specified = language_add($_REQUEST['lang'], $languages); // Set the language in a cookie for a year and for all *.php.net servers - setcookie("MYPHPNET", $_REQUEST['lang'], time() + 60*60*24*365, '/', '.php.net'); + setcookie("LAST_LANG", $_REQUEST['lang'], time() + 60*60*24*365, '/', '.php.net'); } // Specified in a shortcut URL (eg. /en/echo or /pt_br/echo) @@ -77,14 +77,24 @@ // Specified in a manual URL (eg. manual/en/ or manual/pt_br/) if (preg_match("!^/manual/(\\w{2}(_\\w{2})?)(/|$)!", $_SERVER['REQUEST_URI'], $flang)) { $flang = language_add($flang[1], $languages); + + // Set explicity specified language if (empty($explicitly_specified)) { $explicitly_specified = $flang; } + + // Set the language in a cookie for a year and for all *.php.net servers + setcookie("LAST_LANG", $flang, time() + 60*60*24*365, '/', '.php.net'); } // Honor the users own language setting (if available) if (isset($_COOKIE['MYPHPNET'])) { language_add($_COOKIE['MYPHPNET'], $languages); + } + + // Put the last selected language in the priority order (if available) + if (isset($_COOKIE['LAST_LANG'])) { + language_add($_COOKIE['LAST_LANG'], $languages); } // Specified by the user via the browser's Accept Language setting

« previous php.mirrors (#16369) next »