Hi Everton, U can store the locale of the user in a cookie or in db (if u already have a session) and then set the desired locale in a ComponentRequestFilter. It would be something like this:
public class LocaleComponentRenderRequestFilter implements ComponentRequestFilter { private final SecurityContext securityContext; private final PersistentLocale persistentLocale; private final LocalizationSetter localizationSetter; private final Logger logger; /** * @param securityContext * @param persistentLocale * @param logger * @author jmayaalv */ public LocaleComponentRenderRequestFilter(SecurityContext securityContext, PersistentLocale persistentLocale, LocalizationSetter localizationSetter, Logger logger) { super(); this.securityContext = securityContext; this.persistentLocale = persistentLocale; this.localizationSetter = localizationSetter; this.logger = logger; } /** * Changes the locale * @author jmayaalv */ private void changeLocale() { if (this.securityContext.isLoggedIn() && this.persistentLocale.get() == null) { String language = GET LANGUANTE HERE FROM A COOKIE, SESSION OR WHATEVER if (StringUtils.isNotBlank(language) && !"en".equalsIgnoreCase(language)) { if (logger.isDebugEnabled()) { logger.debug("Changing user locale to '{}'", user.getLanguage()); } this.localizationSetter.setLocaleFromLocaleName(language); } } } @Override public void handleComponentEvent(ComponentEventRequestParameters parameters, ComponentRequestHandler handler) throws IOException { changeLocale(); handler.handleComponentEvent(parameters); } @Override public void handlePageRender(PageRenderRequestParameters parameters, ComponentRequestHandler handler) throws IOException { changeLocale(); handler.handlePageRender(parameters); } } After this u just need to contribute the chain in ur module: public static void contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter> configuration, @InjectService("LocaleComponentRenderRequestFilter") ComponentRequestFilter localeFilter) { configuration.add("LocaleFilter", localeFilter); } On Wed, Nov 18, 2009 at 6:37 PM, Everton Agner <everton_ag...@yahoo.com.br> wrote: > Sorry about the previous e-mail title... I was going to change before sending > it and I forgot. > > Well... here's the problem. I didn't explain it well before: > > - My app has 2 Supported Languages : 'pt-BR' (default) and 'en'. > > - By default, when the app is acessed with an Unlocalized URL (like > http://localhost:8181/myapp/start), the framework will identify the Browser's > language, and the current Locale for work will be 'pt-BR' (because of my > browser's language) > > - When the user changes the current Language, every new URL will use the > Locale prefix after the app context... Like > http://localhost:8181/myapp/en/start > > - If I submit a request to an Unlocalized url - like > http://localhost:8181/myapp/start - the framework will not use the stored > Locale for work... So, the request will use the Default Locale ('pt-BR', in > my case) > > There is any way I can change this behavior? We're having these problems > because of a Code-Generation API that is being lost with some URL's creation. > > > Thanks :) > > Everton Agner > > > > ________________________________ > De: Everton Agner <everton_ag...@yahoo.com.br> > Para: Tapestry Users <users@tapestry.apache.org> > Enviadas: Terça-feira, 17 de Novembro de 2009 18:03:30 > Assunto: Localization > > There is any way to call a i18n page without using a localized url? > > Sample: > > 1. User selected some language and that was stored in his session. > 2. When he calls a new url, without the language prefix, the result page > will use the selected language (stored in session), instead of the default > language. > > Thanks, > > Everton > > > > > ____________________________________________________________________________________ > Veja quais são os assuntos do momento no Yahoo! +Buscados > http://br.maisbuscados.yahoo.com > > > > ____________________________________________________________________________________ > Veja quais são os assuntos do momento no Yahoo! +Buscados > http://br.maisbuscados.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org