If you don't want a lot of work you can simply hack Router::url() and add current language to every URL except prefixed ones. Unfortunately there is no way to override this method (at least in 1.2).
Prefixed route will always add prefix to called action, that's why I never ever thought about using it for language control. >From the other side you can get rid of language param in URL and put it as subdomain. In this case no changes needed at all except language detect by hostname in AppController::beforeFilter(). Of course this approach needs default language that will live on original domain. On Jan 14, 2:44 pm, Erik_V <[email protected]> wrote: > Dr Loboto, > > Thank you; your suggestion is exactly what I've been using upto now. > This seems this has one serious drawback: I have to add a > $this->params['language'] to each cake generated link. > > It breaks the automagically generated links and adds a lot of work; or > perhaps I missing something? > > I was hoping to be able to do something like this: > Router::connect('/{$prefix}/:controller/:action/*', > array('controller'=>':controller', 'action'=>':action', > 'prefix'=>null, '{$prefix}'=>true)); > > It would be nice to be able to set the prefix to null, so router > reverts to the standard index.ctp for example and still have a prefix > in the url. > Now, I realize this is not standard cake behaviour. When I set the > prefix to null, the router will still add an underscore to the > controller and view. > > Perhaps something for the devs to consider? > > Thanks, > Erik > > On Jan 14, 5:50 am, "Dr. Loboto" <[email protected]> wrote: > > > > > > > > > Something like this I think: > > > Router::connect( > > array('/:lang/:controller/:action/*'), > > array(), > > array('lang' => 'en|fr') > > ); > > Router::connect( > > array('/:lang/:controller'), > > array('action' => 'index'), > > array('lang' => 'en|fr') > > ); > > > "Standard" routes with language. Plus check $this->params['lang'] in > > AppController::beforeFilter() and set it to default one if empty. > > > On Jan 13, 7:19 pm, Erik_V <[email protected]> wrote: > > > > Hello all, > > > > I'm developing a multi-language site with an single-language admin > > > backend. > > > I would like to use a language and admin prefix in the url like > > > this:http://mysite.com/en/productshttp://mysite.com/fr/categories/view/1ht... > > > > I was thinking of using routing prefixes to achieve that, but I wish > > > to keep the standard controllers and views (index.ctp, view.ctp, > > > admin_index.ctp, etc...) and not have for example: fr_index.ctp or > > > nl_display.ctp... > > > > An added bonus of using routing prefixes would be that setting the > > > locale based on the prefix is trivial. > > > Please note : the admin routing is not an issue; having the language > > > prefixes show up and routed correctly is. > > > > I have looked around and there are a few solutions for what I'm trying > > > to do in 1.2, but my searches for 1.3 come up empty... > > > So, any suggestions or pointers are welcome. > > > > Thank you, > > > Erik Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
