Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #24554

Re: Where did my language setting go?

From markspace <markspace@nospam.nospam>
Newsgroups comp.lang.java.programmer
Subject Re: Where did my language setting go?
Date 2013-07-01 12:09 -0700
Organization A noiseless patient Spider
Message-ID <kqsjra$odd$1@dont-email.me> (permalink)
References <hbd3t8prm69278clpjolii23cuortojbn7@4ax.com> <p7i3t89561o32oj1kaejfdq7ib78e8oolt@4ax.com>

Show all headers | View raw


On 7/1/2013 11:30 AM, Tim Slattery wrote:

> There were two properties files: ces_es.properties with the Spanish
> stuff, and ces.properties with the English language stuff. The page
> examined the Locale, and if it specified Spanish, it did:
>
> <fmt:setBundle basename="ces_es"/>
>
> If the Locale did not specify Spanish it did:
>
> <fmt:setBundle basename="ces"/>
>

I'm kind of confused why it would do this.  I don't really know about 
Struts or even JEE every much, so I'm probably missing something, but 
getLocale() on HttpServletRequest should return the locale requested by 
the browser (client).  Then you should just be able to do this:

ResourceBundle labels = ResourceBundle.getBundle("ces", locale);

without having to have a special check for any language.  It sounds like 
the way you have it you'll need to use some sort of if-else in a cascade 
to fetch additional languages, and that's almost always bad.

More on resources and searching for locales:

http://docs.oracle.com/javase/tutorial/i18n/resbundle/concept.html

'course, I don't know about Struts so I have no idea if this is even 
possible.  However, the attribute for setBundle is "basename" which sure 
sounds to me like it should be doing this search automatically.

If it's not, you might want to find out why.





Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Where did my language setting go? Tim Slattery <Slattery_T@bls.gov> - 2013-07-01 12:59 -0400
  Re: Where did my language setting go? Tim Slattery <Slattery_T@bls.gov> - 2013-07-01 14:30 -0400
    Re: Where did my language setting go? markspace <markspace@nospam.nospam> - 2013-07-01 12:09 -0700
      Re: Where did my language setting go? Tim Slattery <Slattery_T@bls.gov> - 2013-07-01 16:13 -0400
        Re: Where did my language setting go? markspace <markspace@nospam.nospam> - 2013-07-01 13:37 -0700

csiph-web