0
我忙于用ZF1构建一个多语言网站。对于1件事,一切都很好,多语言部分结合zend导航。当我打开开发页面的URL时,标准语言是英语(http://website.nl/en)。导航栏(基于zend导航)显示如下所示:/ en/blog,/ en/events等。但是,当我将德语从英语更改为荷兰语时(http://website.nl/nl),导航栏stil shows/en/home,/ en /博客等Zend Navigation和Zend Locale
有人知道问题是什么吗?
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');
导航代码:路由XML的
$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);
部分
<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>
区域设置插件
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);
}
你知道你在*错* Zend框架;) – markus 2013-02-18 15:09:45