HTTP::negotiateLanguage

From: Date: Sun, 23 Jun 2002 12:44:19 +0000
Subject: HTTP::negotiateLanguage
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7304@lists.php.net to get a copy of this message
Hi, I've made an improvement to the last part of HTTP::negotiateLanguage() (right where it says "Check for a valid language code in the top-level domain of the client's host address"). It's attached. Before, the function would just return the default language if no Accept-Language had been set *and* REMOTE_HOST was not set (which it isn't in most cases since most ISPs turn HostnameLookups off in httpd.conf). Now, the function performs a host name look-up of REMOTE_ADDR. Furthermore, I've removed the regular expression in order to make the function a little faster. However, neither Stig's nor my version is perfect yet. The problem is the fact that the TLDs are not always the same as the language codes. An example: The Danish TLD is ".dk", but the language code for Danish is "da". We need an associative array that links TLDs to language codes. It's not as simple as it may seem, because some countries have several languages, and some languages are spoken in several countries. Furthermore, I'm kinda having doubts about the hyphen in the language codes. Doesn't the standards say that it should be an underscore (i.e., "da_DK" instead of "da-DK", "en_US" instead of "en-US")?

« previous php.pear.dev (#7304) next »