You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2008/01/02 22:22:22 UTC

Re: Internationalization - identification of client request by request header - accept-language ??

Raghuveer wrote:
> How the struts framework does identifies the client language and there by
> uses the Message Resources for Internationalization..

Which version of Struts?

> request.getHeader("accept-language") is giving the string as below
> accept-language-pl,en-us;q=0.7,de;q=0.3
> 
> I need to identify if my request is from polish /English language directly.
> is there facility inside the framework  ?

How about getLocale()? Again, the specifics depend on which version of 
Struts you're using.

> CODE
> 
> Enumeration e=request.getHeaderNames();
> while(e.hasMoreElements()){
>       strTemp=(String)e.nextElement();
>       System.out.println(strTemp + "-"+request.getHeader(strTemp) );
> }

That's just going to print out all the request headers, which might tell 
*you* something when you read the output but isn't going to tell your 
*application* anything at all ;-)

Try Action.getLocale() (assuming you're either using Struts1 or 
extending ActionSupport in Struts2).


L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org