I'd like to which way is the best way to guess what is the user's language without asking him. Here are a couple of options that I've found, but feel free to add any other that you think is worth mentioning.
- Utilice las
$_SERVER['HTTP_ACCEPT_LANGUAGE']a través de PHP
- Use any Maps API (such as Google Maps or Bing Maps) to determine what country the user is accessing the website from (if he is using a modern browser that support location services) and then detect what is that country's official language.
- Have PHP execute a simple shell script (shell_exec()) that send a request to a website like (http://geoip.s12.com.br or similar) to determine what country the user is accessing the website from and then detect what is that country's official language.
- I may be wrong about this one because I didn't make a lot of research about it: Use php's GeoIp function to determine what country the user is accessing the website from and then detect what is that country's official language. (http://www.php.net/manual/en/book.geoip.php)
I am aware that the first one will do in almost any case, however I'd like to know which one is more accurate (the way Facebook or Google use to set your language).
preguntado el 09 de septiembre de 13 a las 23:09
I would go with $_SERVER['HTTP_ACCEPT_LANGUAGE'] mainly due to the fact that it is user configurable.
The issue with geo locating, is that language really shouldn't be tied to a location search. Sure, it would allow you to make an educated guess, but I could easily be vacationing in China, or prefer my internet to be in "language x"
Regardless of the method you use for your educated guess, I would definitely still provide the option to choose their preferred language to override your guess.
There are countries with several languages so 2,3 and 4 won't work at all, so for me, the best opion is to use HTT_ACCEPT_LANGUAGE.