$this->getLocale and $this->setLocale are impossible to work because
$this is the view itself... from within the view you can only call
view helpers. And the error you get is saying that there is no
helper named "getLocale" which is correct... it would also throw an
error on setLocale because the helper is named translate().
The correct way is described within the manual:
$this->translate()->getLocale()
Yes yes I understand this, but my code is the exactly code that you
can find in Zend Framework manual...
Even this (in view): <?php echo $this->translate()->getLocale(); ?>
Will output this error: "Fatal error: Call to a member function
getLocale() on a non-object"
I think that translate() without any string passed as parameter will
not return $this if there is a Zend_Translate instance registered in
Registry as I can understand this code...
PHP never enter in the second IF because Zend_Translate is registered
before (in my Controller) and the "return $this" is never executed.
if ($this->translate === null) {
require_once 'Zend/Registry.php';
if (!Zend_Registry::isRegistered('Zend_Translate')) {
if (empty($messageid)) {
return $this;
} else {
return $messageid;
}
} else {
$this->translate =
Zend_Registry::get('Zend_Translate');
}
}