"Hu, Jeffery X (Jeff)" wrote:
>
>
> Enumeration e = request.getHeaderNames()
>
> while (e.hasMoreElements())
> {
> String KeyValue = (String) e.nextElement();
> if (KeyValue.equals("Accept-Language")
> // e.getHeader(KeyValue) is the locale, ie, en-us
> }
>
This suggestion looks in the right place, but there are some possible
complexities you need to be aware of:
* The "Accept-Language" header may not be present. In fact,
HTTP/1.1 says it MUST NOT be included if the user hasn't
configured their own preferences (in Netscape, for example,
Edit -> Preferences -> Navigator -> Languages).
* The country suffix is not always present -- for example, my
preference is set to "en" not "en-US" because I'm comfortable
with any variant of English (I even know how to spell
"colour" :-). My setting won't help you decide which way
to display dates and times, though, which is something
that Locales are often used for.
* There can be more than one language preference specified,
separated by commas.
* Each language preference can be optionally suffixed by a
"quality" value that weights the user's preference for that
language. The example in the HTTP/1.1 spec looks like:
Accept-Language: da, en-gb;q=0.8; en;q=0.7
which says Danish is preferred, but if not possible then use
British English, then any variant of English.
Craig McClanahan
>
> -----Original Message-----
> From: Ian Holsman [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 27, 1999 1:19 PM
> To: [EMAIL PROTECTED]
> Subject: Getting the Locale from the Browser
>
> hi.
> I would like to get the locale of the user's browser in order to do
> language specific stuff.
> how do I do this ???
>
> Thanks
> Ian.
>
>
> ==========================================================================
>
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html