Details
-
Type:
Sub-task
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 1.9.6
-
Fix Version/s: None
-
Component/s: Zend_Form
Description
There exists an issue with Zend_Form translating labels which becomes apparent when Zend_Translate logging is enabled.
When a form is rendered the form loops through the decorators running their render method. The following code is called as a result of rendering the label.
Zend_Form_Decorator_Label Line #253
$label = $element->getLabel();
$label = trim($label);
if (empty($label)) {
return '';
}
if (null !== ($translator = $element->getTranslator())) {
$label = $translator->translate($label);
}
The above code retrieves the label from the element object and the runs validation methods and then proceeds to translate the message. Below is the code for the $element->getLabel() method.
Zend_Form_Element Line #606
public function getLabel() { $translator = $this->getTranslator(); if (null !== $translator) { return $translator->translate($this->_label); } return $this->_label; }
As you can see this method ALSO translates the text before sending it back to the decorator. This means the Element object is returning translated text back to the decorator which then is attempting to translate already translated text. This causes the Zend_Translate class to log a notice in its log file notifying the user it is missing a translation.
The fix is an obvious one, simply removing the duplicate code from the Zend_Form_Decorator_Label dealing with translation will solve the problem as their corresponding elements should already be translating the content for them.
Please note this also is affecting the Submit button and I have not been able to trace which decorator is causing that problem, although I assume the problem is the same. You will probably want to check through all of the decorators to check if any others are doing the same.
Brad
Attachments
Issue Links
| This issue is duplicated by: | ||||
| ZF-9442 | Zend_Form_Decorator_Label double translates element label |
|
|
|
| ZF-10066 | Double translations on Zend_Form_Decorator_Label and Zend_Form_Element->getLabel() |
|
|
|
| ZF-10128 | Translate is invoked twice |
|
|
|
| ZF-10050 | Translation is executed twice on form labels |
|
|
|
| ZF-10300 | Label gets translated twice |
|
|
|
| ZF-11999 | Zend Form translate Element twice |
|
|
|
| ZF-11332 | Double translation of form element's label |
|
|
|
| ZF-9371 | Zend_Form_Element duplicate and missing label translation Issues |
|
|
|
| This issue is related to: | ||||
| ZF-8764 | Zend_Form_Element_Submit translates the label twice. |
|
|
|
| ZF-9010 | Erros decorator on Zend_Form when grouped does not translate labels |
|
|
|
| This issue is related to: | ||||
| ZF-8713 | Zend_Form_Decorator_FormErrors add translation for Label/Name |
|
|
|
With reference to the final note about the Submit button, this has been reported as ZF-8764.