Uncaught exception 'Zend_Locale_Exception' with message 'The locale '' is no known locale'

1.2k views Asked by At

i'm trying to make the translation of a website in zend framework, but, given that is the first time i use this framework, i'm having some problems. The last one is the one that gives me the error you're seeing as a title here. I've set two important methods in the Bootstrap file:

    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;
}

The problem is that if I want the right translation in my pages i have to set the locale to the $translate variable and set it for every view I'll show to the user. The website has only one page, so i assumed the variable $translate would be avaliable in every action, and i changed the init method of the indexController.php:

     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);
}

The error i'm getting is the following (from 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'

If someone could help it would be much appreciated. Thanks SP

0

There are 0 answers