Open the browser settings, and in the advanced section scroll down to find Languages . Open Language and Input Settings and add the language or language+region choice you want from the list available. Order the resulting list so that it is in descending order of preference.
We can use HTTP_ACCEPT_LANGUAGE key to get the language of the browser. echo substr ( $_SERVER [ 'HTTP_ACCEPT_LANGUAGE' ], 0, 2); ?> You can test it by changing your browser's language.
Try this script to get your browser language
<script type="text/javascript">
var userLang = navigator.language || navigator.userLanguage;
alert ("The language is: " + userLang);
</script>
Cheers
The "JavaScript" way:
var lang = navigator.language || navigator.userLanguage; //no ?s necessary
Really you should be doing language detection on the server, but if it's absolutely necessary to know/use via JavaScript, it can be gotten.
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