Hi, im new here and also new with javascript and was wondering if you guys could help me out?
My friend has been asking me to help him out with a game he has been building and I was wondering if you guys could help me because im stumped
Basically, what he wants to be able to do is when you load the URL the game is on i.e. ‘myfriendsgame.com/game’ he wants it to be able to detect what language the game should be loaded in and whats the url to be similar to this:
Since the script will be reading the language set in the user agent string (which the browser sends when it asks for a page), your friend will have to be aware that the browser language may not be the language spoken by the user (I have browsers in several languages, but if I’m using a browser in a public area in another country, its language is often set to a local language, and not one I speak… happened recently at a conference in Pisa, Italy!).
Also, this will likely have to be a back-end script, or, it would be better as a back-end script. This back-end script will run regardless of whether the user has Javascript enabled or not (unless this is a requirement for the game, in which case, using Javascript is maybe ok), and can talk directly tot the server (who will supply the correct url).
Hm, wait, you mention Flash. Is this going to be done with Javascript, or with Actionscript?
I’d say, you’ll have to ask for the user agent string. I don’t know if that can easily be done.
Your server will always get the language as
HTTP_ACCEPT_LANGUAGE:en-us,en;q=0.5 (example)
but browsers don’t always put the language in the same place, and the Javascript language-detection out there seems stable for… IE and Netscape. Which doesn’t exactly cover all users anymore : )
So I’m still thinking this is better done on the server side. Flash may need to get this straight from the server or from a server-side script.