Zend framework 未捕获的异常“Zend_Locale_exception”,消息为“区域设置“”为未知区域设置”
我试图在zend框架中翻译一个网站,但是,考虑到这是我第一次使用这个框架,我遇到了一些问题。最后一个是给我一个错误,你在这里看到的标题。 我在引导文件中设置了两个重要方法:Zend framework 未捕获的异常“Zend_Locale_exception”,消息为“区域设置“”为未知区域设置”,zend-framework,localization,zend-translate,zend-locale,Zend Framework,Localization,Zend Translate,Zend Locale,我试图在zend框架中翻译一个网站,但是,考虑到这是我第一次使用这个框架,我遇到了一些问题。最后一个是给我一个错误,你在这里看到的标题。 我在引导文件中设置了两个重要方法: protected function _initLocale() { $session = new Zend_Session_Namespace('ttb.l10n'); if ($session->locale) { $locale = new Zend_Locale($session->
protected function _initLocale()
{
$session = new Zend_Session_Namespace('ttb.l10n');
if ($session->locale)
{
$locale = new Zend_Locale($session->locale);
}
if ($locale === null)
{
try
{
$locale = new Zend_Locale('browser');
}
catch (Zend_Locale_Exception $e)
{
$locale = new Zend_Locale('en');
}
}
$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' => 0));
$registry = Zend_Registry::getInstance();
$registry->set('Zend_Translate', $translate);
return $translate;
}
问题是,如果我想在我的页面中使用正确的翻译,我必须将locale设置为$translate变量,并为我将向用户显示的每个视图设置它。该网站只有一个页面,因此我假设变量$translate在每个操作中都可用,并且我更改了indexController.php的init方法:
public function init()
{
/* Initialize action controller here */
$registry = Zend_Registry::getInstance();
//The following is for the links that set the local language manually
$this->view->locale = $this->_getParam('locale');
if(!$this->view->locale){
$this->view->locale = $registry->get('Zend_Locale');
}
$translate->setLocale($locale);
}
我从zend server收到的错误如下:
Function Name Zend_Application::bootstrap
Error Type E_ERROR
Source File /usr/local/zend/apache2/htdocs/project/public/index.php
Error String Uncaught exception 'Zend_Locale_Exception' with message 'The locale '' is no known locale'
如果有人能帮忙,我将不胜感激。
谢谢
SP您的应用程序将使用多种语言来表示国际化,还是使用单一语言,如德语或法语。它使用两种语言,英语和意大利语