������!
As for deciding what your user language/charset requests are (in terms
of his/her browser settings) you might use this function
// this function remains unchanged. It returns an array
// 0 : negotiated charset
// 1 : negotiated lancode
function negotiated_langset() {
// process charset request header and build charset request array
$headchrreq = explode(',',$_SERVER['HTTP_ACCEPT_CHARSET']);
$i = 0;
while ($i<count($headchrreq)) {
$chunk = explode(';',$headchrreq[$i]);
$charsets[$i] = ltrim(rtrim($chunk[0]));
$i++;
}
// process language request header and build language request array
$headlanreq = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$i = 0;
while ($i<count($headlanreq)) {
$chunk = explode(';',$headlanreq[$i]);
$language[$i] = substr(ltrim(rtrim($chunk[0])),0,2);
$i++;
}
// start negotiation
$i = 0;
while ( isset($language[$i]) &&
!$this->has_content($language[$i]) ) { $i++; }
# did we get anything?
if (isset($language[$i])) {
$lancode = $language[$i];
if ($i==0) { $charset=$charsets[0]; }
else {
// default charset when first choice unavailable
$charset="ISO-8859-1";
}
}
else {
// default on nothing found
$charset = "ISO-8859-1";
$lancode = "en";
}
$result[0] = $charset;
$result[1] = $lancode;
return $result;
}
*NOTE* the !$this->has_content($language[$i]) call goes to a local
function of yours that will return true/false, depending on whether you
have available content for this language.
Charset request will default to ISO-8859-1 when your first languace
choice is unavailable, because there is no data about further languages
in the headers. You might want this to became a utf-8 value.
Function will not negotiate charset against content availability (as
usually you will not have separate content editions for different
charsets in your content repository). But you may easily add up the code
snippet needed to do it, if that is your case.
If you do please share the result :)
����
��������
����
@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@
LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
lOrD i'M sHiNiNg...
YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is.......
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php