ZF-6301: Allow user-provided adapters

Issue Type: Improvement Created: 2009-04-15T04:19:59.000+0000 Last Updated: 2009-04-15T10:14:15.000+0000 Status: Resolved Fix version(s): Reporter: Dennis Becker (radhad) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

Related issues: Attachments:


Zend_Translate actually loads adapters only from Zend/Translate/Adapter/* location, but it would be nice if a developer could add a path to his own adapters, which would be located in My/Translate/Adapter/*.

With user-provided adapters, developer could add an own database-translation adapter and use it with Zend_Translate. I have made a small expirement where my adapter (located in Zend/Translate/Adapter/) uses my database model and Zend_Translate automatically caches the result with Zend_Cache.

The "problem" is located in Zend/Translate.php at the setAdapter() method:

<pre class="highlight">
public function setAdapter($adapter, $data, $locale = null, array $options = array())
    if (Zend_Loader::isReadable('Zend/Translate/Adapter/' . ucfirst($adapter). '.php')) {
        $adapter = 'Zend_Translate_Adapter_' . ucfirst($adapter);


Posted by Jan Pieper (jpieper) on 2009-04-15T04:33:27.000+0000

Zend_Translate is only a "factory" like class to instantiate translate adapters. Why aren't you instantiating your class directly?

It isn't the finest way but it should help.



Posted by Dennis Becker (radhad) on 2009-04-15T04:54:03.000+0000

This is a possible way, I haven't checked this solution and I just thought about a more flexible factory pattern implementation, maybe similar to the new Zend\_Application component where you can add more plugin paths.

This is just a small idea from my side :)



Posted by Thomas Weidner (thomas) on 2009-04-15T05:04:15.000+0000

Sorry, but I don't see a problem with this code... You can use ANY properitary adapter by simply giving it:

    <pre class="highlight">
    $translate = new Zend_Translate('My_Own_Properitary_Translation_Adapter', $file, $locale, $options);

It is even written within the manual within a own chapter how to do this: […](



Posted by Dennis Becker (radhad) on 2009-04-15T05:18:12.000+0000

Sorry, seems to be my fault. When I did the tests, I had not seen this chapter in the manual!

I will try this and will report, if it worked for me or not. Thanks for the hint to the manual, it seems I'll have to re-read some hcapters ;)



Posted by Thomas Weidner (thomas) on 2009-04-15T10:14:14.000+0000

Closing as non-issue



Have you found an issue?

See the Overview section for more details.


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

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