cvs: phpweb /include langchooser.inc

From: Date: Sun, 02 Mar 2003 19:33:44 +0000
Subject: cvs: phpweb /include langchooser.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-16017@lists.php.net to get a copy of this message
goba Sun Mar 2 14:33:44 2003 EDT Modified files: /phpweb/include langchooser.inc Log: Adding translation table for pt_br and Chinese language variations and strip out any other language flavor specified in the accept language, as we have no support for flavors of other languages (eg. en-us or en-gb will become en). Index: phpweb/include/langchooser.inc diff -u phpweb/include/langchooser.inc:1.10 phpweb/include/langchooser.inc:1.11 --- phpweb/include/langchooser.inc:1.10 Sun Mar 2 11:16:04 2003 +++ phpweb/include/langchooser.inc Sun Mar 2 14:33:43 2003 @@ -1,6 +1,6 @@ <?php // -*- C++ -*- -// $Id: langchooser.inc,v 1.10 2003/03/02 16:16:04 goba Exp $ +// $Id: langchooser.inc,v 1.11 2003/03/02 19:33:43 goba Exp $ /* @@ -68,10 +68,27 @@ // 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 $langcode) { + + // Get language code part list($langcode) = @explode(";", trim($langcode)); + + // Translation table for accept-language codes and phpdoc codes + switch($langcode) { + case "pt-br" : $langcode = 'pt_br'; break; + case "zh-cn" : $langcode = 'zh'; break; + case "zh-hk" : $langcode = 'hk'; break; + case "zh-tw" : $langcode = 'tw'; break; + } + + // We do not support flavors of languages (except the ones above) + if (preg_match("!^(.+)-!", $langcode, $match)) { + $langcode = $match[1]; + } + + // Add language to priority order language_add($langcode); } -unset($browser_accept); unset($langcode); +unset($browser_accept); unset($langcode); unset($match); // Language preferred by this mirror site language_add(default_language());

« previous php.mirrors (#16017) next »