I define a translation pattern in one of my plugin and it work fine in the views but i have other plugin witch create an html for menus and i need it to fill with curent translation of worlds , but when i use :
public function preDispatch(Zend_Controller_Request_Abstract $request){
.......
$translate = Zend_Registry::get('Zend_Translate');
$translate->_($Nrow['name']);
.......
It give me :
Message: No entry is registered for key 'Zend_Translate'
But if i use print_r($translate);
it shows content of my translation file .
And When i use print_r(get_class_methods($translate));
it returns :
Array ( [0] => __construct [1] => setAdapter [2] => getAdapter [3] => getCache [4] => setCache [5] => hasCache [6] => removeCache [7] => clearCache [8] => __call )
I use these code in my translation plugin to set registery:
Zend_Registry::set('Zend_Translate',$translate);
What should i do ?
As i understand preDispatch run before calling Zend_Registry , If you want to have Zend_Registry keys , you should put code in postDispatch function in Zend_Controller_Plugin_Abstract or in your plugin class.
Code change to these and problem solved :
public function preDispatch(Zend_Controller_Request_Abstract $request){
.......
$translate = Zend_Registry::get('Zend_Translate');
$translate->_($Nrow['name']);
.......
for more info look at :
http://devzone.zend.com/1224/front-controller-plugins-in-zend-framework/