frigozend wrote
> I would like to create a MENU with different items in different languages
> (Spanish and English), using Zend_translage and Zend_navigation
> components. 
> 
> 
> Until now , I have achieved:
> 
> Menu works in only one language.
> All contents in my layouts or views can be translated to all languages.
> 
> My bootstrap file:
> 
>    
> 
>    function _initSetTranslations()
>     {
>         $this->bootstrap('layout');
>         $layout = $this->getResource('layout');
>         $view = $layout->getView();
> 
> 
> $english = array('documental' => 'The Documentary','equipo' => 'The
> Team','productores' => 'The Producers');
> $spanish = array('documental' => 'El Documental','equipo' => 'El
> Equipo','productores' => 'Los Productores');
> 
> 
> $translate = new Zend_Translate(array('adapter' => 'array','content' =>
> $english,'locale'  => 'en'));
> $translate->addTranslation(array('content' => $spanish, 'locale' =>
> 'es'));
> 
> 
>  $view->translate = $translate;  
> 
>     }
> 
> 
>       protected function _initNavigation()
>       {
> 
>       
> 
>               $layout = $this->getResource('layout');
>               $view = $layout->getView();
> 
> 
>    $pages = array(
>       array('controller'=> 'index','action' => 'documental','label'=>
> $view->translate->_("documental"),),                                          
>                                                                               
>                    
>       array('controller'=> 'index','action' => 'equipo','label'=>
> $view->translate->_('equipo'),),
>       array('controller'=> 'index','action' => 'productores','label'=>
> $view->translate->_("productores"),),
>       );
>     
>     $translate = new Zend_Navigation($pages);
> 
> 
> 
>       $view->navigation($translate);  
>     
> 
> 
>       }       
> 
> }
> 
> In my Layout:
> 
>   $this->translate->setLocale('es'); 
>               
>   echo $this->navigation()->menu(); 
> 
> 
>     
> 
> It shows the menu Items always in English, although 'es' is selected. Does
> anybody know how to change the language in the menu items?

Try to set your Locale and Translations into Registry on Bootstrap like in
the sample below.
Then construct your Navigation in your default Controller or Plugin. Once
you call echo $this->navigation()->menu(); in your view then you should be
able to see correct translations.

protected function _initLocale()
  {
    $session = new Zend_Session_Namespace('square.l10n');
    if ($session->locale) {
      $locale = new Zend_Locale($session->locale);
    }

    if (!isset($locale)) {
      try {
        $locale = new Zend_Locale('browser');
      } catch (Zend_Locale_Exception $e) {
        $locale = new Zend_Locale('en_GB');
      }
    }

    $registry = Zend_Registry::getInstance();
    $registry->set('Zend_Locale', $locale);
  }


  protected function _initTranslate()
  {
    $translate = new Zend_Translate('array', APPLICATION_PATH .
'/../languages/',
      null, array('scan' => Zend_Translate::LOCALE_FILENAME,
'disableNotices' => 1));
    $registry = Zend_Registry::getInstance();
    $registry->set('Zend_Translate', $translate);
  }




-----
Cheers,
--
Luke Mierzwa
--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-with-Translations-tp4656968p4656979.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to