Zend Framework

Zend_Translate_Adapter does not properly handle numeric key values

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9.0
  • Fix Version/s: 1.9.2
  • Component/s: Zend_Translate
  • Labels:
    None

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.

Activity

Hide
Thomas Weidner added a comment -

And you know that using numeric keys for translation is a absolute no go and not supported ?

Show
Thomas Weidner added a comment - And you know that using numeric keys for translation is a absolute no go and not supported ?
Hide
Jan Gorman added a comment -

No, I didn't know that and it worked just fine in every version up to 1.8.4pl1

Show
Jan Gorman added a comment - No, I didn't know that and it worked just fine in every version up to 1.8.4pl1
Hide
Thomas Weidner added a comment -

Fixed with r17760.
Note that using numeric keys for translation is a VERY unsave behaviour. Strongly discuraged.

Show
Thomas Weidner added a comment - Fixed with r17760. Note that using numeric keys for translation is a VERY unsave behaviour. Strongly discuraged.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: