Issues

ZF-11272: Zend_Controller_Router not working with Zend_Translate translations with underscore characters

Issue Type: Bug Created: 2011-04-07T20:07:40.000+0000 Last Updated: 2011-04-16T21:55:47.000+0000 Status: Open Fix version(s): Reporter: Sebastian Grodzicki (sgrodzicki) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Controller_Router

Related issues: Attachments:

Description

Consider the following Bootstrap file:

<pre class="highlight">
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initRouting()
    {
        $this->bootstrap('frontController');
        
        $front  = $this->getResource('frontController');
        $router = $front->getRouter();
        $route  = new Zend_Controller_Router_Route(
            ':@country/:@slug', 
            array(
                'controller'    => 'index',
                'action'        => 'index',
                'slug'          => '',
            ), 
            array(
//              'country'       => '(France|Germany|Poland)',       // Working
                'country'       => '(_France|_Germany|_Poland)',    // Not working
                'slug'          => '[A-Za-z\d\-]+',
            )
        );
        
        $router->removeDefaultRoutes();
        $router->addRoute('sample', $route);
    }
    
    protected function _initTranslate ()
    {
        $this->bootstrap('Routing');
        
        $translator = new Zend_Translate(
            array(
                'adapter'   => 'array',
                'content'   => array(
//                  'France'    => 'Francja',   // Working
//                  'Germany'   => 'Niemcy',    // Working
//                  'Poland'    => 'Polska',    // Working
                    '_France'   => 'Francja',   // Not working
                    '_Germany'  => 'Niemcy',    // Not working
                    '_Poland'   => 'Polska',    // Not working
                ),
                'locale'    => 'pl',
            )
        );
        
        $translator->setLocale('pl');

        Zend_Controller_Router_Route::setDefaultTranslator($translator);
    }
}

and the following URL:

http://localhost/public/Niemcy/Niemcy

The problem always occurs when the key has an underscore so it can also be:

"under_score_France", "__France" and so on.

Comments

Posted by Thomas Weidner (thomas) on 2011-04-16T21:55:47.000+0000

Detaching Zend_Translate from the affected components as it's no problem from this component

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts