ZF-5928: getList() returns only current value and not all available lanuages in case we use Zend_Translate+Zend_Cache

Issue Type: Bug Created: 2009-03-03T02:59:25.000+0000 Last Updated: 2009-03-11T01:23:39.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: Joseph Chereshnovsky (webdevbyjoss) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

Related issues: Attachments: -


According API docs: {quote} getList Zend_Translate_Adapter::getList() in Adapter.php Returns the available languages from this adapter {/quote}

But it returns only language code for current (default) cached language, instead of returning the list of all available languages in translation data source.

This is a problem for me as I'm using the getList() method to extract values and build the languages selectbox to allow user to select interface language.

Will attach the code to reproduce this error


Posted by Joseph Chereshnovsky (webdevbyjoss) on 2009-03-03T03:06:05.000+0000

according the attached code sample:

Refresh the page couple times and you will see only one language in the list, even if we have three languages available in translation data source.

Clear the cache and you will see all three languages in the list, but only for this time. Refresh again and you will see one language in the list again.

Posted by Thomas Weidner (thomas) on 2009-03-03T04:46:55.000+0000

getList() returns all loaded languages. This is independently of which language has been set.

So when the language is not loaded, it will not be returned.

I expect that you are having problems eighter with your implementation or with your cache. I am not able to reproduce this behaviour on my system.

Posted by Joseph Chereshnovsky (webdevbyjoss) on 2009-03-03T07:32:43.000+0000

My implementation actually is a quite simple script with only 46 lines. You can find it in attached "". Can you please try it? ( tmp/ subdirectory must be writable)

All code works great if we disable Zend_Cache

I've perfomed some debug using ZendDebuger and found the following:

  1. During the first run of the script, Zend_Translate_Adapter loads the metadata (available languages) from translation source (TMX file in my case), and tranlation data only for current language (locale).

Then it writes all information into cache using Zend_Cache instance. As only current locale data was loaded then we have translation information cached only for one (current) locale.

  1. After we refresh the page, - Zend_Translate loads data from cache now and not from original translation data source. So we receiving only one language available in ->getList() method because we have cached information for one locale.

I've found this code in Zend/Translate/Adapter.php

monospaced if (isset(self::$cache)) { $id = 'Zend_Translate' . preg_replace('/[^a-zA-Z0-9_]/', '', $data) . '' . $locale . '_' . $this->toString(); $result = self::$_cache->load($id); if ($result) { $this->_translate[$locale] = unserialize($result); $read = false; } }

    if ($read) {
        $this->_loadTranslationData($data, $locale, $options);


If cache exists it loads the information from cache and "$read = false;" indicates that we don't need to read translation source file. Here is our issue: We have information only for ONE locale in the cache, and there is no any information about other locales available in the cache. Thats why when we calling ->getList() method we receiving only one available language instead of the list of available languages.

I can reproduce this on my clear install of ZendServer + WinXP + ZF 1.8dev (lates co from SVN)

Posted by Joseph Chereshnovsky (webdevbyjoss) on 2009-03-11T00:59:39.000+0000

I saw your last commit according this issue. I've tested new code and it looks OK right now, so I think the issue can be closed. Thanks.

Posted by Thomas Weidner (thomas) on 2009-03-11T01:23:38.000+0000

Reworked cache handling with r14274 which solves also this issue.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.