T
Tim Slattery
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.
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.