Zend router with Zend Translate: default locale region issues (updated)

Let’s say we have a zend TMX translator

$routeTranslator = new Zend_Translate(
  'tmx',
  '/path/to/tmxFiles/',
  'en_GB' 
);
Zend_Controller_Router_Route::setDefaultTranslator($routeTranslator);

With this entry

 
 
   archive
   archive-all 
   archivio 


Now, lt’s add the route with translated segment.

$route = new Zend_Controller_Router_Route(
 '@archiveroute',
   array(
     'controller' => 'archive',
     'action'     => 'index'
   )
);

If the application locale is en_GB, the dispatch of the URL

/archive

will work only if (1) the xml:lang attribute of the tuv element is using the case xx_YY (2) the locale used for Zend_Translate constructor is using the case xx_YY.
If the locale is en_IE, the result will be route not found, as the route will be

/archiveroute

Zend_Translate_Adapter_Tmx does not warn if the TMX file is not valid. In order to prevent that, add a check in the bootstrap (or create a resource) that warns if an expected translation is not found in a certain file.

One thought on “Zend router with Zend Translate: default locale region issues (updated)

  1. Pingback: PHP Web Developer - Wordpress Video Tutorials

Comments are closed.