ZF-2256: Possibility to give a string as the source files in the array adapter Zend_Translate_Adapter_Array

Issue Type: Improvement Created: 2007-12-03T10:38:08.000+0000 Last Updated: 2008-03-21T16:25:21.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Laurent Melmoux (laurent melmoux) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

Related issues: Attachments:


It can easily implement by adding 3 lines of code in Zend_Translate_Adapter_Array::_loadTranslationData()

<pre class="highlight">

    $data = include($data); 

Then the array file should look like :

<pre class="highlight">
return array(
    'user_id'  => 'Id',
    'username' => 'Non utilisateur',
    'password' => 'Mot de passe',
    'email'    => 'Email',
    'firstname'=> 'Prénom',
    'lastname' => 'Nom',
    'created'  => 'Crée le',
    'modified' => 'Modifié le'


Posted by Thomas Weidner (thomas) on 2007-12-03T13:07:18.000+0000

Why should an Array Adapter accept Strings ?

As per definition of the class name the usage is for "Arrays"... You can simply extend any existing adapter or write your own.

But I don't think that a "string" Adapter is usefull, because you could simply do

<pre class="highlight">
$t->addTranslation(array($key => $value));

Posted by Laurent Melmoux (laurent melmoux) on 2007-12-03T13:56:56.000+0000

Well, if you can do both its even better don't you think? :) There are a lot of classes in the frameworks were the argument is an object or a string, and in the later it will use a factory to get the object. So it could be done with array too.

But best, if you can provide a string the array adapter will work with the automatic source detection. My $0.2

Posted by Thomas Weidner (thomas) on 2007-12-06T07:49:41.000+0000

It's not just that 3 lines. We have also to handle output and failures from the file.

Anyway, it has been integrated with SVN-7050.

Posted by Laurent Melmoux (laurent melmoux) on 2007-12-06T08:09:49.000+0000

Thanks Thomas ! :)

{quote} It's not just that 3 lines We have also to handle output and failures from the file. {quote}

That's right.

I think there is a more appropriated test

<pre class="highlight">

Instead of the one I first suggested

<pre class="highlight">

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.