Hi Rob, I have come up with my own plugin that auto loads the translations and caches them. The code may not be perfect but hopefully it gives you an idea:
<BEGIN> class MyPlugin_Language extends Zend_Controller_Plugin_Abstract { public function preDispatch(Zend_Controller_Request_Abstract $request) { $locale = new Zend_Locale(); /** * Cache options */ $frontendOptions = array('cache_id_prefix' => 'MyApp', 'lifetime' => 86400); $backendOptions = array('cache_dir' => 'cache'); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); Zend_Translate::setCache($cache); $options = array('scan' => Zend_Translate::LOCALE_DIRECTORY); /** * Scan languages dir. For CSV language files. Auto-detect browser * language settings */ $translate = new Zend_Translate('csv', 'languages', 'auto', $options); /** * If browser language setting is not available default to English */ if (!$translate->isAvailable($locale->getLanguage())) { $locale->setLocale('en'); } $translate->setLocale($locale); Zend_Registry::set('Zend_Translate', $translate); } } <END> Cheers, - Robert -----Original Message----- From: Rob L [mailto:[EMAIL PROTECTED] Sent: 07 April 2008 21:45 To: fw-general@lists.zend.com Subject: [fw-general] Zend_Translate doesn't cache when addTranslation is called I wrote a custom adapter and am trying to load 13 different languages from files. I can't simply read the entire directory because I am using non-standard locale names and need full control. So in my bootstrap I call the Zend_Translate constructor for my first language and then call addTranslation for each of the remaining languages. All of the languages get cached, but only the Zend_Translate constructor actually checks to see if a language has been cached. If you call addTranslation directly, it *always* calls the adapter to load the file. For now as a workaround, I manually check to see if Zend_Cache already has the key 'Zend_Translate_[my adapter here]' cached. But really, Zend should simply check the cache for a hit every time addTranslation is called, right? Rob -- View this message in context: http://www.nabble.com/Zend_Translate-doesn%27t-cache-when-addTranslation-is- called-tp16539888p16539888.html Sent from the Zend Framework mailing list archive at Nabble.com. ________________________________________________________________________ This email has been scanned for all known viruses by the MessageLabs Email Security Service and the Macro 4 plc internal virus protection system. ________________________________________________________________________ ________________________________________________________________________ This email has been scanned for all known viruses by the MessageLabs Email Security Service and the Macro 4 plc internal virus protection system. ________________________________________________________________________