Issues

ZF-8713: Zend_Form_Decorator_FormErrors add translation for Name

Description

This function doesn't translate the label/name


    /**
     * Render element label
     *
     * @param  Zend_Form_Element $element
     * @param  Zend_View_Interface $view
     * @return string
     */
    public function renderLabel(Zend_Form_Element $element, Zend_View_Interface $view)
    {
        $label = $element->getLabel();
        if (empty($label)) {
            $label = $element->getName();
        }

        return $this->getMarkupElementLabelStart()
             . $view->escape($label)
             . $this->getMarkupElementLabelEnd();
    }

You could resolve this with


    public function renderLabel(Zend_Form_Element $element, Zend_View_Interface $view)
    {
        $label = $element->getLabel();
        if (empty($label)) {
            $label = $element->getName();
        }
        $translator = $element->getTranslator();
        return $this->getMarkupElementLabelStart()
             . $view->escape($translator->translate($label))
             . $this->getMarkupElementLabelEnd();
    }

Comments

you can close

A similar solution was implemented for {{Zend_Form_Element_Submit}} previously as part of ZF-8764:


/**
 * Return label
 *
 * If no label is present, returns the currently set name.
 *
 * If a translator is present, returns the translated label.
 *
 * @return string
 */
public function getLabel()
{
    $value = parent::getLabel();

    if (null === $value) {
        $value = $this->getName();

        if (null !== ($translator = $this->getTranslator())) {
            return $translator->translate($value);
        }
    }

    return $value;
}

Is it OK to change it here as well? Or, would changing the label translation in FormErrors at this stage constitute a BC break?

Fixed on trunk (25256) and release-1.12 (25257)