John Taylor-Johnston wrote:

This is what http_accept_language gives me depending on which browser. Depending on the visitor in my region, it will either be French or English.

_SERVER["HTTP_ACCEPT_LANGUAGE"] en-us,en;q=0.8,fr;q=0.5,fr-ca;q=0.3
_SERVER["HTTP_ACCEPT_LANGUAGE"] fr-ca,en-us;q=0.5


Is this a reasonable approach?

if(stristr($_SERVER["HTTP_HOST"],"fr"))
{ include("french.htm");}else{ include("english.htm");}

No it's not unless you want to ignore the users preferred language. The order is important in that header - the first language is the preferred language. So in the first example you should serve english.htm and french.htm in the second. If you only have english and french, your best bet is to do the following...

if (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == 'fr')
{
   include('french.htm');
}
else
{
   include('english.htm');
}

However, if you don't care about their preferred language, and want to serve french.htm if they specify french at all in their language preferences then what you've got will do that.

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to