franceav Posted May 27, 2009 Share Posted May 27, 2009 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 More sharing options...
AElliott Posted May 27, 2009 Share Posted May 27, 2009 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 More sharing options...
justsomeguy Posted May 27, 2009 Share Posted May 27, 2009 Check here:http://w3schools.invisionzone.com/index.php?showtopic=24813(why would someone spoof their language?) Link to comment Share on other sites More sharing options...
AElliott Posted May 27, 2009 Share Posted May 27, 2009 Not saying they specifically would, I just tend to be over paranoid of anything user controlled, and those things happen to be one. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 27, 2009 Share Posted May 27, 2009 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 More sharing options...
AElliott Posted May 27, 2009 Share Posted May 27, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.