How can I get and parse Accept Header to get language as two character => en, tr, ar, fr, etc. at JavaScript?
EDIT: When I use
navigator.language
or something like that it gives me a language. However I am using a plug-in at Firefox, Quick Locale, it changes the local. When I change it from English to Arabic, still navigator.language says that I am using English. However when I connect to www.google.com, after I changed locale with Quick Locale, Google's homepage opens at Arabic language. I want to detect the user's language as like that. I will load the language properties of my HTML file after I detected the language as like Google.
EDIT2: There is a code for my purpose here: accept header script
However it makes a call to that URL: http://ajaxhttpheaders.appspot.com
How can I get the source code at that URL?
EDIT3: Can I write something similar to that code at my server side (to communicate my HTML side via REST - this is last solution for me) ?
You can't. But you can try to detect browser language.
Edit: If you would like to change site content depending on accept header (like google) then you have to do it on server side.
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