I'm busy building a multi language website with ZF1. Everything works well expect for 1 thing, the multi language part in combination with zend navigation. When I open the URL of the development page, the standard language is English (http://website.nl/en). The navigationbar (based on zend navigation) shows de urls like this: /en/blog, /en/events etc. But when I change de language from English to Dutch (http://website.nl/nl) the navigation bar stil shows /en/home, /en/blog etc.
Does someone know what the problem is ?
Routingcode:
// Routing
$front = Zend_Controller_Front::getInstance();
// Remove default router
$router = $front->getRouter();
$router->removeDefaultRoutes();
// Add routers from config
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/routes.xml');
$router->addConfig($config, 'routes');
Navigation code:
$this->bootstrap('layout');
$this->bootstrap('view');
$layout = $this->getResource('layout');
$view = $layout->getView();
// Set path to navigation.xmls
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml');
// ACL
$acl = new Application_Model_Acl();
// Get the identity of the user
$auth = Zend_Auth::getInstance()->getIdentity();
$navigation = new Zend_Navigation($config);
$view->navigation($navigation)
->setAcl($acl)
->setRole($auth->role);
Part of the routing xml
<cameloth type="Zend_Controller_Router_Route_Hostname">
<route>websiteurl</route>
<defaults _layout="sitecameloth/layout" module="siteCameloth" />
<chains>
<locale>
<route>:locale</route>
<defaults controller="index" locale="en" />
<reqs locale="[a-z]{2,3}" />
<chains>
<index>
<route></route>
<defaults _layout="sitecameloth/front" action="index" />
</index>
<news>
<route>blog</route>
<defaults controller="news" />
<chains>
<list>
<route>:page</route>
<defaults action="list" page="1" />
</list>
<read>
<route>:id/:title</route>
<defaults action="read" />
</read>
</chains>
</news>
Locale plugin
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$lang = $request->getParam('locale', '');
if ($lang !== 'en' && $lang !== 'nl')
$request->setParam('locale', 'en');
$lang = $request->getParam('locale');
if ($lang == 'en')
$locale = 'en_US';
else
$locale = 'nl_NL';
$zl = new Zend_Locale();
$zl->setLocale($locale);
Zend_Registry::set('Zend_Locale', $zl);
$translate = new Zend_Translate('gettext', APPLICATION_PATH . '/languages/' . $locale . '.mo');
Zend_Registry::set('Zend_Translate', $translate);
}