ZF-11575: Creating translated URLs by the router in assemble() function

Description

There is a problem when generating translated URLs with default params via Zend_Controller_Router.

h3.+EXAMPLE:+


resources.router.routes.language.type = Zend_Controller_Router_Route
resources.router.routes.language.route = ":language"
resources.router.routes.language.reqs.language = "^(en|pl)$"
resources.router.routes.language.defaults.language = "en"

resources.router.routes.defaultraw.type = Zend_Controller_Router_Route  
resources.router.routes.defaultraw.route = :@controller/:@action/*
resources.router.routes.defaultraw.defaults.module = "default"
resources.router.routes.defaultraw.defaults.controller = "index"
resources.router.routes.defaultraw.defaults.action = "index"    

resources.router.routes.default.type = Zend_Controller_Router_Route_Chain
resources.router.routes.default.chain = "language, defaultraw"

Zend_Translate defines: ||English (en)||Polish (pl)|| |index|glowna|

As you can see the default action is index (pl: glowna) and default controller is index too. I'd like to generate URL to index controller and index action by assemble() function (Zend_Controller_Router) It works well in english which is default language (http://example.com/en), but if I set polish it generates link like this: http://example.com/pl/glowna/glowna. "glowna/glowna" is unnecessary, because these parameters are default!

h3.+PATCH:+

It only requires one line change :-)

Class: Zend_Controller_Router_Route Function: assemble() Line: 397

Change:


if ($this->_isTranslated && $defaultValue !== null && isset($this->_translatable[$this->_variables[$key]])) {

to


if ($this->_isTranslated && $defaultValue !== null) {

Thanks for your patience

Enjoy ;-)

Comments

Może byście się pospieszyli :/