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 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: References: 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: Xref: csiph.com comp.lang.java.programmer:24554 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: > > > > If the Locale did not specify Spanish it did: > > > 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.