Issues

ZF-2919: Zend_Translate will not default to English if requested locale is not found

Description

This is in repsect to ZF-2908

I have made the suggested changes to my code. I know have:


public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
      $locale = new Zend_Locale();
      $translate = new Zend_Translate('csv', 'languages', 'browser', array('scan'=>Zend_Translate::LOCALE_DIRECTORY));
      $translate->setLocale('browser');
      Zend_Registry::set('Zend_Translate', $translate);

If I don't use:


$translate->setLocale('browser');

it seems to display the values of the last language file loaded.

A couple of things to note:

1) My language files are stored like so:


languages
  -->en
    -->lang.en
  -->de
    -->lang.de
  -->fr
    -->lang.fr
etc.

2) If I set my browser to e.g. Cambodian(km) I will only see messageIds in my view. How do I get this to default or downgrade to English. In 1.0.4 using the addTranslation it use to downgrade through the available languages sent by the browser i.e. if I had km -> es -> en in my list it would display English if I did not have km and es translations available.

Also, Zend_Translate is not available Zend_View_Helper_MyHelper via $this->translate, I get an undefined method. The docs seem to say that you can use $this->translate in helpers as long as you store $translate in the registry key Zend_Translate which I have done. $this->translate is available in script views i.e. index.phtml.

Sorry to be a pain!

Comments

Duplicated entry... already answered... see ZF-2908

I'm assuming this fix is merged to the 1.5 release branch for release with 1.5.1. Please update JIRA if this is not the case.