It seems to me that neither PersistentLocale nor LocalizationSetter
truly force desired locale for the request. After implementing
solution suggested here, I'm still exhibiting undesired bahavior, that
is stripping locale from the URL makes tapestry use browser's locale,
not the one I have forced. In the LocaleRequestFilter service (for
simplicity sake) I am brute forcing french locale for every request:

persistentLocale.set(new Locale("fr"));

(my browser's locale is en_us). When I request my home page, English
locale is nevertheless (I expected french), and then subsequently
Tapestry renders all links and forms with an /fr/ suffix since that's
what I forced. Functionally this is not what I want. Here is how we
currently handle localisation: http://www.avenuesupply.ca - notice it
is URL agnostic.

My team is just starting a huge project to rewrite this very large
ecommerce app from Struts 1 to Tapestry. This codebase has several
deployments, but this particular deployment is localized, and in the
current Struts version, we are using pure Servlet API to accomplish
this, which is actually very, very simple. We have a LocaleFilter
which checks HttpSession for selected language value, and if found, it
creates an instance of HttpServletRequestWrapper with a forced locale.
Struts doesn't even know (or care) what happened. By the time request
hits the framework it has the desired locale.

Here is a snippet from our servlet filter in the current non-Tapestry version:

if(BooleanUtils.isTrue(isLocaleForced)) {
  requestToFilter =
    new LocaleHttpServletRequestWrapper(aRequest, forcedlocale);
  response.setLocale(forcedlocale);
}

I know in Tapestry I can disable URL localisation by contributing
false for SymbolConstants.ENCODE_LOCALE_INTO_PATH.

So I *could* do it like this with Tapestry by extending Tapestry's
filter, but that's not in the spirit of Tapestry. Furthermore, the
framework is famous for making things amazingly simple. I think I'm
missing something. What is it?

Adam

On Wed, Jul 14, 2010 at 11:56 AM, Thiago H. de Paula Figueiredo
<thiag...@gmail.com> wrote:
> On Wed, 14 Jul 2010 13:36:50 -0300, Adam Zimowski <zimowsk...@gmail.com>
> wrote:
>
>> @Persist
>> private String language;
>
> You should use @SessionState instead and then use the
> ApplicationStateManager to read or set it.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to