I created a PHP script that checks the HTTP_ACCEPT_LANGUAGE
and loads the website using the appropriate language from the 1st two characters:
$http_lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
switch ($http_lang) {
case 'en':
$SESSION->conf['language'] = 'english';
break;
case 'es':
$SESSION->conf['language'] = 'spanish';
break;
default:
$SESSION->conf['language'] = $PREFS->conf['languages'][$SESSION->conf['language_id']];
}
If I change the language to Spanish in Firefox the website loads in Spanish fine. However I have had several reports that people in Colombia see the website in english.
Details: "es-co" LCID = 9226 Spanish(Colombia)
Anyone have any ideas as to why this is happening? I thought this was the best way to check what language users support.
Do you know if this is happening for all visitors to your site from Colombia? Users are usually free to alter the language settings of their browsers — or to have them altered for them by whoever is in charge of the computer. As zerkms recommends, try logging IP addresses and their headers.
If you have the intl extension installed you can use
Locale::lookup
andLocale::acceptFromHttp
to get a best-fit choice of language from the users browser settings and a list of what translations you have available.