ZF-6647: Labels not translated

Issue Type: Bug Created: 2009-05-14T00:18:53.000+0000 Last Updated: 2009-06-24T09:58:44.000+0000 Status: Resolved Fix version(s): Reporter: Fabien Dehopré (fabien1979) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: Attachments: - ZF-6647.patch


the getLabel() method of Zend_Form_Element does not perform translation as described in the doc (…)


Posted by Danne Lundqvist (dotvoid) on 2009-05-19T08:02:41.000+0000

It seems that there is no translator returned in the label decorator for file elements. The method called is Zend_Form_Element_File::getTranslator() which in the end is calling Zend_File_Transfer_Adapter_Abstract::getTranslator()

The code in Zend_File_Transfer_Adapter_Abstract does not return the default translator if there is not a specific one assigned. Replacing the code in Zend_File_Transfer_Adapter_Abstract::getTranslator() with the below (from Zend_Form_Element::getTranslator()) fixes the problem and make sure the default translators is returned.

    if ($this->translatorIsDisabled()) {
        return null;

    if (null === $this->_translator) {
        require_once 'Zend/Form.php';
        return Zend_Form::getDefaultTranslator();
    return $this->_translator;

Posted by Marco Kaiser (bate) on 2009-05-19T13:35:50.000+0000

added patch for this issue

Posted by Mike Willbanks (digitalstruct) on 2009-06-23T18:24:06.000+0000

I don't believe that adding the form translator into the Zend_File_Transfer_Adapter_Abstract is the correct fix for this. It would seem that it would be a better fix to put this into the Zend_Form_Element_File area and setting it from there rather than adding additional complexity and coupling the File_Transfer_Adapter to the form.

Posted by Mike Willbanks (digitalstruct) on 2009-06-23T18:53:59.000+0000

I cannot reproduce this bug in the trunk:

<pre class="highlight">
        require_once 'Zend/Translate.php';
        $translate = new Zend_Translate('array', array('foo' => 'bar'), 'en');

        $form = new Zend_Form();
        $element = new Zend_Form_Element_File('file');
        $form->setView(new Zend_View());

        $html = (string) $form;

Posted by Matthew Weier O'Phinney (matthew) on 2009-06-24T09:18:16.000+0000

Confirmed Mike's diagnosis -- on trunk, this is working fine. Closing; re-open if you can provide reproduce code off of current trunk that shows labels not being translated.

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.