I have a zend framework project with zend version 1.12. I´m using zend_navigation with a xml file and zend_translation with the gettext adapter.
This code creates the main menu:
echo '<ul class="nav1">';
foreach ($this->container as $page) {
// check if it is active (not recursive)
$isActive = $page->isActive(false);
$liClass = $isActive ? ' class="active"' : '';
echo '<li ' . $liClass . '>' . $this->menu()->htmlify($page);
// subnavigation in second layer
if (sizeof($page) > 0) {
echo '<ul class="subNavHead">';
foreach ($page as $subpage) {
$isActive = $subpage->isActive(false);
$liClass = $isActive ? ' class="active"' : '';
echo '<li ' . $liClass . '>' . $this->menu()->htmlify($subpage) . '</li>';
}
echo '</ul>';
}
echo '</li>';
}
echo '</ul>';
And here is my language selector class:
class AW_Controller_Plugin_LangSelector extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request) {
$lang = $request->getParam('lang', '');
if ($lang !== 'de' && $lang !== 'en' && $lang !== 'pl')
$request->setParam('lang', 'de');
switch ($request->getParam('lang')) {
case 'de':
$locale = 'de';
break;
case 'en':
$locale = 'en';
break;
case 'pl':
$locale = 'pl';
break;
default :
$locale = 'de';
break;
}
$zl = new Zend_Locale();
$zl->setLocale($locale);
Zend_Registry::set('Zend_Locale', $zl);
$translate = Zend_Registry::get('Zend_Translate');
$translate->setLocale($zl);
}
}
When I change the language with a select box the text on my site change the language, but the navigation targets don´t change. The navigationlabels changes too.
When I am in default language : www.example.de/de/controller/action And then I switch the language to English -> the href attributes of my navigation are still on the old value (www.example.de/de/controller/action) but they should have www.example.de/en/controller/action
Where is my problem? Have I forget to re-render the menu?