ZF-2291: Trim whitespace in CSV files


Currently language files built using CSV have a typical syntax such as:



In order to make the CSV more human readable (but at the same time kinda breaking the CSV principles) I would like to have the option to layout the CSV like so:

#param      value
hello:      Bonjour
car:        Voiture
green:      Vert

In Zend_Translate_Adapter (ZF 1.0.3) line 354 I can mimic this functionality by changing:

return $this->_translate[$locale][$messageId];


return trim($this->_translate[$locale][$messageId]);

I think what would be better is to allow this to be provided in the $option array.


2 things to beware of:

First: CSV files are not intended to be "human readable" in a stylish way. When whitespaces appear then they will also be included in any CSV import. This would f.e. break excel, word and any other software you or your customer are using for editing this, except a plain text editor.

Second: Translation means that the text is returned as it is. There must be no formatting, striooing and so on. Sometimes whitespaces are necessary and should be returned.

The aproved way for this is to write a small helper which does this for you within the view. Zend_Translate will not truncate or change any output it reads. This is part of the view.

Therefor this improvement will not be integrated.