Issue Details (XML | Word | Printable)

Key: ZF-6647
Type: Bug Bug
Status: Resolved Resolved
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Matthew Weier O'Phinney
Reporter: Fabien Dehopré
Votes: 4
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

Labels not translated

Created: 14/May/09 12:18 AM   Updated: 24/Jun/09 09:58 AM   Resolved: 24/Jun/09 09:58 AM
Return to search "Fixed in 1.5.1"
Component/s: Zend_Form
Affects Version/s: 1.8.1
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Text File ZF-6647.patch (0.4 kB)



 Description  « Hide

the getLabel() method of Zend_Form_Element does not perform translation as described in the doc (http://framework.zend.com/manual/en/zend.form.i18n.html#zend.form.i18n.standard)



Danne Lundqvist added a comment - 19/May/09 08:02 AM

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;


Marco Kaiser added a comment - 19/May/09 01:35 PM

added patch for this issue


Mike Willbanks added a comment - 23/Jun/09 06:24 PM

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.


Mike Willbanks added a comment - 23/Jun/09 06:53 PM

I cannot reproduce this bug in the trunk:

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

        Zend_Form::setDefaultTranslator($translate);
        $form = new Zend_Form();
        $element = new Zend_Form_Element_File('file');
        $element->setLabel('foo');
        $form->addElement($element);
        $form->setView(new Zend_View());

        $html = (string) $form;

Matthew Weier O'Phinney added a comment - 24/Jun/09 09:18 AM

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.