Is there any way to parse the HTTP_USER_AGENT to get the current user language ?
Try:
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
echo $lang;
You may want to try HTTP_ACCEPT_LANGUAGE in the $_SERVER superglobal.
Take a look at http://php.net/manual/en/reserved.variables.server.php for more information.
This will return a value like 'en-us' which you can then break down as needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With