The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Update hidden field with visitor language
Hello,
I can't find a solution to automatically add a language code (en/fr/es, etc.) into a hidden field value based on the visitor browser language (or if not possible based on the URI).
Anny suggestions?
Thanks,
Frederic
December 7, 2018 at 3:46 pm
I don't know that you can do that. Just because a person is in a specific location doesn't mean that they speak the language. What happens if a visitor is from one country and visiting another?
Maybe this will give you some insight. https://medium.com/@adeyinkaadegbenro/how-to-detect-the-location-of-your-websites-visitor-using-javascript-92f9e91c095f
December 10, 2018 at 7:19 am
Hello,
In fact we just want to know their language, the country is not important for us.
Any clue how to add the browser language or add it based on the page url?
Thanks,
Frederic
December 10, 2018 at 8:58 am
You can try this Javascript:
var language = window.navigator.userLanguage || window.navigator.language;
December 10, 2018 at 9:47 am
As I'm not a programmer, were do I add it so that it is added to the hidden field value?
Thanks!
Frederic
Discussion closed.