sub lang : Chained('/') CaptureArgs(1) PathPart(''){ my ($self, $c, $lang) = @_;
# need to check that $lang is valid and handle that here if (valid($lang)) { } else { } } sub doit : Chained('lang') Args(0) { my ($self, $c) = @_; } this now matches /*/doit, and doit needs to be able to rely on the language being in the stash. in fact there are a number of ways the language can be detected. For me, these are (highest priority first) ... : 1. the uri 2. the session (maybe, i'm thinking about this ... the argument is that the user shouldn't have to manually set the language twice while a cookie persists). 3. the browser settings. so we need to try these in turn ... as soon as we get a valid value, set it in the session/stash where all downstream actions get it. On 8/10/06, Matt S Trout <[EMAIL PROTECTED]> wrote: > Renaud Drousies wrote: > > On Thu, August 10, 2006 4:39 pm, Matt S Trout said: > >> sub lang :Chained('/') :CaptureArgs(1) :PathPart('') { > >> my ($self, $c, $lang) = @_; > >> <set lang appropriately> > >> } > >> > >> sub foo :Chained('/lang') :Args(0) { # /en/foo etc. > >> > >> Chained was designed to support this sort of stuff without the need for > >> prepare_path hacks, which I've used before but always found a tad ugly. > >> > > > > But then I am not sure to understand how to dispatch actions correctly to > > different controllers. This looks like all actions must be defined in the > > same controller. > > No, that "sub foo" could be in any controller. > > > If I have that 'sub lang' in my Root controller, how can I reach my > > original 'sub index: Private' in MyApp::C::Foo (or any other action > > defined there) so that the Foo controller is used when I request /en/foo? > > read the Catalyst::DispatchType::Chained POD first. If you still have > questions, ask 'em then :) > > _______________________________________________ > List: Catalyst@lists.rawmode.org > Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ > Dev site: http://dev.catalyst.perl.org/ > -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/