Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24554
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED.99-92-208-198.lightspeed.sntcca.sbcglobal.net!not-for-mail |
|---|---|
| From | markspace <markspace@nospam.nospam> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Where did my language setting go? |
| Date | Mon, 01 Jul 2013 12:09:38 -0700 |
| Organization | A noiseless patient Spider |
| Lines | 39 |
| Message-ID | <kqsjra$odd$1@dont-email.me> (permalink) |
| References | <hbd3t8prm69278clpjolii23cuortojbn7@4ax.com> <p7i3t89561o32oj1kaejfdq7ib78e8oolt@4ax.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Mon, 1 Jul 2013 19:04:10 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="99-92-208-198.lightspeed.sntcca.sbcglobal.net:99.92.208.198"; logging-data="25005"; mail-complaints-to="abuse@eternal-september.org"; posting-account="markspace" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 |
| In-Reply-To | <p7i3t89561o32oj1kaejfdq7ib78e8oolt@4ax.com> |
| Xref | csiph.com comp.lang.java.programmer:24554 |
Show key headers only | 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
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