[Catalyst] Chained actions and uri_for

Renaud renaud at linuxaddicts.com
Tue Nov 14 14:12:54 GMT 2006


Hello,

I understood that using the Chained actions way would be the more proper
way to design an "uri-based" multilangual application. In my case, I have
to extract a province and a language from my url, so here is how I coded
it:

In Root.pm:

sub province : Chained('/') :CaptureArgs(1) :PathPart('') { ... }
sub lang : Chained('province') :CaptureArgs(1) :PathPart('') { ... }

In other controllers, e.g Foo.pm:
sub foo : Chained('/lang') : Args(0) { ... }

That will be triggered with /*/*/foo

The problem is that I am not sure how to properly use uri_for with that.
What I'd like is to have something like uri_for('/foo') returning
http://whatever.com/qc/fr/foo if $province eq 'qc' and $lang eq 'fr'.

What I am doing so far is concatenating uri_for('/'), $province and
$language into one "root" variable and using href="[% root %]/foo" in my
templates. There must be a more "catalystic" way to do that, but I can't
figure it out. Would anyone have a clue for me?

Actually, is there anything written about the best practices to code a
multilanguage catalyst application? There are so many ways to do it
(Chained, prepare_path,...), I'm quite sure it would help a lot of people,
including me :)

Thanks,
Renaud




More information about the Catalyst mailing list