Hi David,
 
As per your suggestion, I have put a page up on the Wiki:
 
http://framework.zend.com/wiki/x/p6o <http://framework.zend.com/wiki/x/p6o> 
 
Cheers,
 
- Robert

  _____  

From: David Rogers [mailto:[EMAIL PROTECTED] 
Sent: 08 April 2008 12:49
To: Robert Castley
Subject: Re: [fw-general] Zend_Translate doesn't cache when addTranslation
is called


Is there a snippet board somewhere in the ZF project? It would be invaluable
to keep this little code piece around for the community, methinks.

David

On Apr 8, 2008, at 5:48 AM, Robert Castley wrote:


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); 
    } 
} 



________________________________________________________________________
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.
________________________________________________________________________

Reply via email to