Issues

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

Description

Consider the following Bootstrap file:


<?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

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