You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ch...@expeditors.com on 2006/02/17 21:48:15 UTC
Localizing a single page (in an app that's localized in different language)
Greetings,
I?m trying to change the locale of only 1 page in my web app. The system
as a whole allows for a variety of locales, but 1 page in particular is
displayed in a data specified locale. I?ve tried
myPage.setLocale(Locale.GERMAN), before activating the page, but that just
seems to result in a ApplicationRuntimeException. So I created a work
around, in the specially localized page I did:
public void pageBeginRender(PageEvent event) {
super.pageBeginRender(event);
if (!event.getRequestCycle().isRewinding()) {
Locale dataLocale = new Locale(getData().getLanguage());
if (getEngine().getLocale().equals(dataLocale) == false)
{
getEngine().setLocale(dataLocale);
event.getRequestCycle().cleanup();
throw new PageRedirectException(this);
}
AppVisit visit = (AppVisit) getVisit();
App app = visit.getSession();
getEngine().setLocale(app.getDefaultLocale());
}
}
Which should check to see if the current locale is different than the data
locale, change the engine locale to the data locale, refresh the page. If
the two locales are the same, then reset the locale to the default locale.
This seems to work fairly well, except when the user logs out. When the
user logs out we do ((IEngineServiceView)
cycle.getEngine()).restart(cycle), and redirect to the login page. When
that redirection happens, the user?s locale seems to be whatever the data
locale was.
So as an example, the user logs in in English, browses to the data sees it
in German, then browses other pages (back in English). When the user logs
out, for some reason they get presented with a German login screen. Their
browser is set to English, the session default is English, only that data
page is in German.
Mostly I dislike messing with the engine locale, I?d like to just set it
for the specific page, but I haven?t figured out how.
Ideas for what I?m doing wrong, or possible alternatives?
Thanks!
Chris
Re: Localizing a single page (in an app that's localized in different
language)
Posted by Ch...@expeditors.com.
I should have specified, I'm using tapestry 3.0.3.
Jesse Kuhnert <jk...@gmail.com>
02/17/2006 12:59 PM
Please respond to
"Tapestry users" <ta...@jakarta.apache.org>
To
Tapestry users <ta...@jakarta.apache.org>
cc
Subject
Re: Localizing a single page (in an app that's localized in different
language)
I don't remember the exact syntax offhand, but I think you can use one of
the "meta" tags in your page spec to set this.
On 2/17/06, Chris.McCurdy@expeditors.com <Ch...@expeditors.com>
wrote:
>
> Greetings,
> I?m trying to change the locale of only 1 page in my web app. The
system
> as a whole allows for a variety of locales, but 1 page in particular is
> displayed in a data specified locale. I?ve tried
> myPage.setLocale(Locale.GERMAN), before activating the page, but that
just
> seems to result in a ApplicationRuntimeException. So I created a work
> around, in the specially localized page I did:
>
> public void pageBeginRender(PageEvent event) {
> super.pageBeginRender(event);
> if (!event.getRequestCycle().isRewinding()) {
> Locale dataLocale = new Locale(getData().getLanguage());
> if (getEngine().getLocale().equals(dataLocale) == false)
> {
> getEngine().setLocale(dataLocale);
> event.getRequestCycle().cleanup();
> throw new PageRedirectException(this);
> }
>
> AppVisit visit = (AppVisit) getVisit();
> App app = visit.getSession();
>
> getEngine().setLocale(app.getDefaultLocale());
> }
> }
>
>
> Which should check to see if the current locale is different than the
data
> locale, change the engine locale to the data locale, refresh the page.
If
> the two locales are the same, then reset the locale to the default
locale.
>
>
> This seems to work fairly well, except when the user logs out. When the
> user logs out we do ((IEngineServiceView)
> cycle.getEngine()).restart(cycle), and redirect to the login page. When
> that redirection happens, the user?s locale seems to be whatever the
data
> locale was.
>
> So as an example, the user logs in in English, browses to the data sees
it
> in German, then browses other pages (back in English). When the user
logs
> out, for some reason they get presented with a German login screen.
Their
> browser is set to English, the session default is English, only that
data
> page is in German.
>
> Mostly I dislike messing with the engine locale, I?d like to just set it
> for the specific page, but I haven?t figured out how.
>
> Ideas for what I?m doing wrong, or possible alternatives?
>
> Thanks!
>
> Chris
>
Re: Localizing a single page (in an app that's localized in different language)
Posted by Jesse Kuhnert <jk...@gmail.com>.
I don't remember the exact syntax offhand, but I think you can use one of
the "meta" tags in your page spec to set this.
On 2/17/06, Chris.McCurdy@expeditors.com <Ch...@expeditors.com>
wrote:
>
> Greetings,
> I?m trying to change the locale of only 1 page in my web app. The system
> as a whole allows for a variety of locales, but 1 page in particular is
> displayed in a data specified locale. I?ve tried
> myPage.setLocale(Locale.GERMAN), before activating the page, but that just
> seems to result in a ApplicationRuntimeException. So I created a work
> around, in the specially localized page I did:
>
> public void pageBeginRender(PageEvent event) {
> super.pageBeginRender(event);
> if (!event.getRequestCycle().isRewinding()) {
> Locale dataLocale = new Locale(getData().getLanguage());
> if (getEngine().getLocale().equals(dataLocale) == false)
> {
> getEngine().setLocale(dataLocale);
> event.getRequestCycle().cleanup();
> throw new PageRedirectException(this);
> }
>
> AppVisit visit = (AppVisit) getVisit();
> App app = visit.getSession();
>
> getEngine().setLocale(app.getDefaultLocale());
> }
> }
>
>
> Which should check to see if the current locale is different than the data
> locale, change the engine locale to the data locale, refresh the page. If
> the two locales are the same, then reset the locale to the default locale.
>
>
> This seems to work fairly well, except when the user logs out. When the
> user logs out we do ((IEngineServiceView)
> cycle.getEngine()).restart(cycle), and redirect to the login page. When
> that redirection happens, the user?s locale seems to be whatever the data
> locale was.
>
> So as an example, the user logs in in English, browses to the data sees it
> in German, then browses other pages (back in English). When the user logs
> out, for some reason they get presented with a German login screen. Their
> browser is set to English, the session default is English, only that data
> page is in German.
>
> Mostly I dislike messing with the engine locale, I?d like to just set it
> for the specific page, but I haven?t figured out how.
>
> Ideas for what I?m doing wrong, or possible alternatives?
>
> Thanks!
>
> Chris
>