Zend Framework

Zend_Translate with the gettext adapter returns an unexpected result when called with an empty string

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.5.2
  • Fix Version/s: 1.6.0
  • Component/s: Zend_Form
  • Labels:
    None

Description

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.

Eg:

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

or 

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

Will output something like

<option value="" label="Project-Id-Version: removed
Report-Msgid-Bugs-To: 
POT-Creation-Date: 2008-07-23 22:23-0500
PO-Revision-Date: 
Last-Translator: removed
Language-Team: 
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
" selected="selected">Project-Id-Version: removed
Report-Msgid-Bugs-To: 
POT-Creation-Date: 2008-07-23 22:23-0500
PO-Revision-Date: 
Last-Translator: removed
Language-Team: 
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
</option>

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

Thank you.

Activity

Hide
Matthew Weier O'Phinney added a comment -

Assigning to Thomas.

Show
Matthew Weier O'Phinney added a comment - Assigning to Thomas.
Hide
Thomas Weidner added a comment -

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.

Show
Thomas Weidner added a comment - 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.
Hide
Matthew Weier O'Phinney added a comment -

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.

Show
Matthew Weier O'Phinney added a comment - 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.
Hide
Thomas Weidner added a comment -

New feature implemented with r10517.

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

Show
Thomas Weidner added a comment - New feature implemented with r10517. Empty translations are now suppressed by the gettext adapter. Adapter informations can be retrieved with the new 'getAdapterInfo()' method.
Hide
Wil Sinclair added a comment -

Updating for the 1.6.0 release.

Show
Wil Sinclair added a comment - Updating for the 1.6.0 release.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
Not Specified
Original Estimate - Not Specified
Remaining:
0m
Remaining Estimate - 0 minutes
Logged:
1h
Time Spent - 1 hour