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


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

Where did my language setting go?

From Tim Slattery <Slattery_T@bls.gov>
Newsgroups comp.lang.java.programmer
Subject Where did my language setting go?
Date 2013-07-01 12:59 -0400
Organization A noiseless patient Spider
Message-ID <hbd3t8prm69278clpjolii23cuortojbn7@4ax.com> (permalink)

Show all headers | View raw


I've got a web system written with Struts 1.3.10 that has to display
in English or Spanish. The front page always should display in
English, then the user can click a button to switch the language. It's
supposed to work this way even if the browser's language preference is
Spanish. Seems a bit odd to me too, but that's how the powers-that-be
want it.

The way it works is that a language preference is passed into the
front page. The app used this to create a Locale object specifying the
appropriate language, then uses the Struts method setLocale to save it
in the session object. It then does whatever else it needs to do and
forwards to the JSP page. The page retrieves the Locale and uses it to
determine which language to show.

The problem is that I print the saved Locale object just before
forwarding to the page. It's right, it says English when the page is
first requested without a language preference set. But when the
browser's language preference is Spanish, the page shows in Spanish.
And I can't switch it to English. Clicking the "English" link results
in a Spanish page even though the app is setting up the Locale object
correctly. I can only figure that the Locale is getting reset between
the forward command and handing control to the page. Does that make
any sense?

When the browser's language preference is English, it works right. I
get English first, and I can switch the language to Spanish.

-- 
Tim Slattery
Slattery_T@bls.gov

Back to comp.lang.java.programmer | Previous | Next — 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