PhpRiot
Follow phpriot on Twitter
Sponsored Link
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

Integrate self written Adapters

Zend_Translate allows you to integrate and use self written Adapter classes. They can be used like the standard Adapter classes which are already included within Zend_Translate.

Any adapter class you want to use with Zend_Translate must be a subclass of Zend_Translate_Adapter. Zend_Translate_Adapter is an abstract class which already defines all what is needed for translation. What has to be done by you, is the definition of the reader for translation datas.

The usage of the prefix "Zend" should be limited to Zend Framework. If you extend Zend_Translate with your own adapter, you should name it like "Company_Translate_Adapter_MyFormat". The following code shows an example of how a self written adapter class could be implemented:

<?php
try {
    
$translate = new Zend_Translate(
        array(
            
'adapter' => 'Company_Translate_Adapter_MyFormat',
            
'content' => '/path/to/translate.xx',
            
'locale'  => 'en',
            
'myoption' => 'myvalue'
        
)
    );
} catch (
Exception $e) {
    
// File not found, no adapter class...
    // General failure
}

Zend Framework