You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tomas Kolda <ko...@web2net.cz> on 2008/12/26 18:32:17 UTC

Set locale using url

Hello all,

I'm new to Tapestry and maybe I want to do something non-standard. I 
want to set locale using urls.

http://www.example.com/en/...../
http://www.example.com/fr/...../

I also write simple filter that do setting of locale, but I need to 
change something that strips language from URL so Tapestry can map to 
right page. After that I need to change LinkFactory to generate right 
links?

public boolean service(Request request, Response response, 
RequestHandler handler) throws IOException
        {
            String path = request.getPath();
            Pattern p = Pattern.compile("^/([a-z]{2})/.*");
            Matcher m = p.matcher(path);
            if (m.find()) {
                this.localizationSetter.setThreadLocale(new 
Locale(m.group(1)));               
            }
            // Here change request??
            return handler.service(request, response);
        }

I'm the first who is trying this or is it already implemented? As a 
newbie I do not know internals of Tapestry... mod_rewrite is the last I 
want to use...

Thank you
Tomas


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


Re: Set locale using url

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 27 Dec 2008 11:04:20 -0300, Tomas Kolda <ko...@web2net.cz>  
escreveu:

> I made a  workaround through Servlet filter.

You could also use a Tapestry RequestFilter, avoiding a servlet filter and  
having all the Tapestry infrastructure. :)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Set locale using url

Posted by Tomas Kolda <ko...@web2net.cz>.
I made a  workaround through Servlet filter. It create delegate request 
object that moves locale folder from path to context and also put locale 
object to request attributes. When I set FORCE_ABSOLUTE_URIS it works 
fine. I will test it more and then we can create a recipe on web.

But if it will be part of Tapestry, that will be great.

Tomas

Angelo Turetta napsal(a):
> Tomas Kolda wrote:
>> Hello all,
>>
>> I'm new to Tapestry and maybe I want to do something non-standard. I 
>> want to set locale using urls.
>>
>> http://www.example.com/en/...../
>> http://www.example.com/fr/...../
>
> Funny, just a few days ago Howard posted a Jira about that:
>
> https://issues.apache.org/jira/browse/TAP5-422
>
> I'd suggest: wait and see if hls lands a built-in solution before 
> cooking your own, or contact him and offer your help.
>
> Angelo.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

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


Re: Set locale using url

Posted by Angelo Turetta <at...@bestunion.it>.
Tomas Kolda wrote:
> Hello all,
> 
> I'm new to Tapestry and maybe I want to do something non-standard. I 
> want to set locale using urls.
> 
> http://www.example.com/en/...../
> http://www.example.com/fr/...../

Funny, just a few days ago Howard posted a Jira about that:

https://issues.apache.org/jira/browse/TAP5-422

I'd suggest: wait and see if hls lands a built-in solution before 
cooking your own, or contact him and offer your help.

Angelo.

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