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.
- Use
$_SERVER['HTTP_ACCEPT_LANGUAGE']
via 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).