ZF-6301: Allow user-provided adapters

Description

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:


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

Comments

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.

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 :)

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


$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: http://framework.zend.com/manual/en/…

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

Closing as non-issue