ZF-7560: Zend_Translate_Adapter does not properly handle numeric key values
Description
I have come across an issue in Zend_Translate_Adapter with the use of numeric keys in a translation file. In the translation file (CSV) I have a couple of keys for translating formRadio-Labels:
4;Vor mehr als 4 Wochen 2;Vor weniger als 4 Wochen 0;Neueinzug
In Zend_Translate_Adapter the keys get mangled up, I have tracked the issue down to the use of {{array_merge}} on Line 481 in the method {{_addTranslationData}}
{{$this->_translate[$key] = array_merge($this->_translate[$key], $temp[$key]);}}
{{array_merge}} does not preserve numeric key values. The issue could be fixed by changing the line to
{{$this->_translate[$key] = $this->_translate[$key] + $temp[$key];}}
Using the union operator, the translation works fine again.
Comments
Posted by Thomas Weidner (thomas) on 2009-08-22T14:35:12.000+0000
And you know that using numeric keys for translation is a absolute no go and not supported ?
Posted by Jan Gorman (polygraf) on 2009-08-22T15:14:15.000+0000
No, I didn't know that and it worked just fine in every version up to 1.8.4pl1
Posted by Thomas Weidner (thomas) on 2009-08-22T15:23:07.000+0000
Fixed with r17760. Note that using numeric keys for translation is a VERY unsave behaviour. Strongly discuraged.