ZF-3749: Zend_Translate with the gettext adapter returns an unexpected result when called with an empty string


When Zend_Translate (used with the gettext adapter) is fed an empty string, it returns a long string of header file information (see ZF-2914). This is the normal behaviour.

However, when Zend_Form uses Zend_Translate in a similar context, the output is not appropriate.

For example, if I have a list for which I want the first entry to be empty (so there is no default selection made), the label of that first entry (an empty string) is being translated by the gettext adapter to the string of system info. This is obviously not what I want.


$form->birthYear->addMultiOption('', '');


$form->birthYear->addMultiOption(null, null);

Will output something like

Project-Id-Version: removed
POT-Creation-Date: 2008-07-23 22:23-0500
Last-Translator: removed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Poedit-Language: English
X-Poedit-Country: CANADA
X-Poedit-SourceCharset: utf-8
X-Poedit-KeywordsList: translate
X-Poedit-Basepath: removed
X-Poedit-SearchPath-0: removed

I believe this behaviour, which has been corrected for fieldset labels (ZF-2913), should also be corrected for field labels.

Thank you.


Assigning to Thomas.

For your information: This is not a bug of Zend_Translate.

When gettext files are compiled with poEdit the editor adds it's own information as translation of an empty string. ALL translations are used and returned, of course also an empty translation.

So the general question is:

Do we want to suppress the informations when they are provided ? Or do we change Zend_Form to "not translate" empty strings.

Suppressing the informations raise another possible problems... other editors could add such information in a different translation. As mentioned this is a poEdit ONLY problem which adds this information as translation for an empty string.

As Thomas notes, this is not a bug in Zend_Translate, and Zend_Translate is only doing Zend_Form's bidding; ultimately, it's a poEdit issue.

I'm closing this, as there's no reasonable solution on the framework side.

New feature implemented with r10517.

Empty translations are now suppressed by the gettext adapter. Adapter informations can be retrieved with the new 'getAdapterInfo()' method.

Updating for the 1.6.0 release.