Jump to content

How To Auto Detect Browser Language And Direct Page


franceav

Recommended Posts

I have a web site which has 2 languages English and Chinese, how could i make the index page auto select different language and redirect to a page according to different browser language(the index.php is only for redirecting), in my case it's English and Chinese, I heard that Javascript has limited functionality for this,can anyone give some sample code or useful resources, many thanks!

Link to comment
Share on other sites

You could make a best guess from the estimated location of that IP address (Geolocation), and then provide an option to switch language in a fairly prominent location. You could then use a cookie as the main determining factor, and that would override geolocation if the user has set their own language. Geolocation can be a bit flaky and inaccurate, so you do need the option to switch.Browser variables are also a plausible way of trying to determine language, but they can easily be spoofed and inaccurate too.Most websites tend to just ask once though.

Link to comment
Share on other sites

Right, but you want to deliver the content that the user wants, so if the user's claiming that they want content in Esperanto, it's not incorrect for your site to deliver the page in Esperanto, regardless of whether or not the user manually edited that in the browser. This is just a user preference, it doesn't matter if the user manually edited it or if the browser is detecting the OS settings or what. It's fine to be paranoid about user data, but make sure you know where the line is. If I'm on my laptop in Japan and sites are delivering content to me based on my IP instead of my language header, it would be a little irritating.

Link to comment
Share on other sites

Hence why I was advocating a user override because things could be incorrect?EDIT: my concern was simply about accuracy, and overall, the user knows best what they want. So I was suggesting whatever automated method they go by an option should be given that lets them opt for their own language option. It seems we're in agreement, so I'm not sure where we're going here. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...