Send it via javascript on IE?
navigator.browserLanguage
: browser language
navigator.systemLanguage
: Windows system language
navigator.userLanguage
: Windows user-specific language
Thanks to: Is there anyway to detect OS language using javascript?
That's the only way besides the one you've mentioned to get the language of the client OS, PHP is run by the server and nothing else.
Build a PHP sorting function.
HTTP_ACCEPT_LANGUAGE: zh,en-US;q=0.8,en;q=0.6
zh
and en-US
share the same q=
value, meaning that you can sort on the highest language value and default to en-US if the quality is the same on two languages.
Just noticed that @Quentin mentioned this in the comment section a minute before my edit, well done sir!
Mockup:
$languages = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$default = 'en-US';
/*
* magic split and structure the language into a array sorted by quality
*
* $languages_sorted_by_quality = array(0.8 => ('zh', 'en-US'));
*/
$top_languages = max($languages_sorted_by_quality);
if (isset($top_languages[$default])) {
$language = $default;
else
$language = $top_languages[0];