dennylin93 Posted April 3, 2007 Share Posted April 3, 2007 I'm trying to create a website in both English and Chinese, so I am trying to make it show up the browser's default language. I saw a site (http://jigsaw.w3.org/css-validator/) that can automatically show the language that is set as the browser's default. How can I do this? Thanks in advance. Link to comment Share on other sites More sharing options...
real_illusions Posted April 3, 2007 Share Posted April 3, 2007 All language conversion kits i've seen cost money. Although i maybe wrong on that. Its been a while since i've looked at it. Either way, you will need a server side language to change the language of the page, or, create 2 versions of your site, and get the user to click on their language before entering. The latter will require alot of work, both now and in the future, but the first one will save alot of time in the future.Have a look around for "website language conversions" or something along those lines. See what you can find.Hope that helps:) Link to comment Share on other sites More sharing options...
justsomeguy Posted April 3, 2007 Share Posted April 3, 2007 If you want to auto-detect the language that the browser is reporting, the best way would probably be to look in the Accept-Language request header. Here is the HTTP/1.1 spec, scroll down to 14.4 to see the description of Accept-Language:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.htmlBut not all browsers will send that header. If the header is not present, then you might want to look in the user agent string for the browser. Many browsers will put the language somewhere in the user agent string, like this:Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101That example is from the Mozilla page on guidelines for creating the user agent string:http://www.mozilla.org/build/revised-user-agent-strings.htmlNot all browsers use that format (in fact, most do not). Here is a page that lists user agent strings for a lot of different browsers:http://www.pgts.com.au/pgtsj/pgtsj0208c.htmlYou'll need to look in that list and figure out some regular expressions to use to capture whatever browsers you want to target. You'll notice that some browsers do not put the language in the user agent string, so for some people you will not be able to tell. Link to comment Share on other sites More sharing options...
dennylin93 Posted April 4, 2007 Author Share Posted April 4, 2007 Thanks. I'll try it out. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now