ZF-9720: Stopped working automatic loading of translations from directory by filename

Description

Thats the way I had initialized Zend_Translation in bootstrap: <?php $locale = new Zend_Locale(); Zend_Registry::set('Zend_Locale', $locale); $translate = new Zend_Translate(Zend_Translate::AN_ARRAY, APPLICATION_PATH . '/../languages/', 'auto', array( 'scan' => Zend_Translate::LOCALE_FILENAME, 'log' => Zend_Registry::get('Zend_Log'), 'logUntranslated' => true, )); Zend_Registry::set('Zend_Translate', $translate); ?>

In languages folder create two translation files en.php and lt.php. Internaly those files looks like:

<?php /** * English language file */ return array( 'token1' => 'text in english1', 'token2' => 'text in english2' ); ?>

This part was working perfectly until I had made upgrade of ZF to 1.10.3. Sad, can't say what version was before. I guess 1.9.x. After some debugging I had realized, that Zend_Translate_Adapter_Array::_loadTranslationData as $data parameter can accept only string with path to translation or array of such strings for multiple translation files. Zend_Translate_Adapter_Array::_addTranslationData doesn't do anything with $data value, simply passes it to _loadTranslationData. But structure of array passed has all (except the first) arguments passed to Zend_Translate constructor.

If in Zend_Translate_Adapter_Array::addTranslation method after line with this code:

<?php $options = $options + $this->_options; ?>

I add something like this:

<?php if (is_array($data) && !empty($data['content'])) { $data = $data['content']; } ?>

Translations start to work again. If that is really the way component is intended to be used, then I think this issue is feature breaker.

Comments

Sorry for editing it so much times, didn't expect it will save all edits..

Not reproduceable in trunk.

In line 126, if options is a string (note that it should be an array according to API doc) it is converted to array('content' => options) which itself is accepted by addTranslation().

Using your example all works without problems without any changes to the component.