0

How do I have to set up the routing for a default language in Zend Framework on a custom module, in my case the admin module.

I have the following code:

$langRoute = new Zend_Controller_Router_Route(
   ':lang/admin',
   array(
      'lang' => 'ro',
   )
);

what i wan't to obtain is url's like the following:

www.example.com/ro/admin/pages/add/62
www.example.com/ro/admin/pages/index/by/date_modified/order/asc

etc.

Ashwin Parmar
  • 3,025
  • 3
  • 26
  • 42
Tudor Ravoiu
  • 2,130
  • 8
  • 35
  • 56
  • How to change the default `lang` at run time when click on other language option from web sit?. – Ashwin Parmar Oct 15 '13 at 09:06
  • @AshwinP I don't really get what you mean. – Tudor Ravoiu Oct 15 '13 at 09:11
  • In your Zend Controller Router you have added default lang ( language ) is set to 'ro' so, How can use change language from ro to like en, nl or hi etc... – Ashwin Parmar Oct 15 '13 at 09:20
  • I have another plugin that init's after the Translation and gets the language of the user. But this is not my problem, the user locale is detected correctly. I only don't know how to set it up for modules. Links like www.example.com/ro and www.example.com route both to the ro version, like i wan't it, but this doesn't happen for modules. – Tudor Ravoiu Oct 15 '13 at 09:25

1 Answers1

0

Try this will working:

protected function _initRoutes() {
    $langRoute = Zend_Controller_Front::getInstance ()->getRouter ();
    $langRoute->removeDefaultRoutes ();
    $route = new Zend_Controller_Router_Route(
       ':lang/:module/:controller/:action/*',
        array (
            'lang' => 'ro',
            'module' => 'admin',
            'controller' => 'index',
            'action' => 'index'
        )
    );
    $langRoute->addRoute ( 'langrouter', $route );
}
Ashwin Parmar
  • 3,025
  • 3
  • 26
  • 42
  • It kind of works but what it doesn't work is the default url for example: www.example.com/admin/pages/index should route to default "ro". Do you know what I should add? – Tudor Ravoiu Oct 15 '13 at 11:25