-- Jon <[EMAIL PROTECTED]> wrote
(on Wednesday, 24 October 2007, 09:35 PM +0100):
> I want to prefix the usual <module>/<controller>/<action> URL route with a
> language ID.
> 
> So for example, www.mydomain.com/news/view/item would become www.mydomain.com/
> en/news/view/item or www.mydomain.com/de/news/view/item depending on the
> language being viewed. I’m unsure of how to achieve this. I have been through
> the manual pages regarding this sort of thing for the front controller but I
> can’t seem to get it working. I’m using a Conventional Modular Directory
> Structure so would this mean I have to specify a custom route for each module?

You have two options. One is to create your own default route by
extending Zend_Controller_Router_Route_Module and modifying it to check
for a language segment in the first path position. The second is to
strip it off the request URI and pass the modified request URI to
the request object in your bootstrap:

   $uri = $_SERVER['REQUEST_URI'] ;
   if (preg_match('#^/([a-z]{2})/#', $uri, $matches)) {
       Zend_Registry::set('language', $matches[1]);
       $request = new Zend_Controller_Request_Http();
       $uri     = substr($uri, 4);
       $request->setRequestUri($uri);
       $front->setRequest($request);
   }

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to