ZF-9885: CLONE -logging not found translations does not work with Zend_Validate, Zend_Form_Element_Multi, Zend_Dojo_Form_Element_DijitMulti

Issue Type: Bug Created: 2010-05-25T07:33:05.000+0000 Last Updated: 2010-06-07T09:22:39.000+0000 Status: Resolved Fix version(s): - 1.10.6 (22/Jun/10)

Reporter: Eric Jeker (keilnoth) Assignee: Thomas Weidner (thomas) Tags: - Zend_Dojo

  • Zend_Form
  • Zend_Validate

Related issues: Attachments:


Not found translations are logged in the translators translate() Method if the translations does not exist.

Zend/Validate/Abstract.php, Zend/Form/Element/Multi.php and Zend/Dojo/Form/Element/DijitMulti.php first check if there is an existing translation with isTranslated() and only if theres a translation the translate() Method is called. If the translation does not exist, the translation won't be logged because of the missing call of translate()!

I've two ways to solve this problem:

  • change Zend_Validate_Abstract etc. to just call translate() instead of checking if there is an existing translation


  • enable logging of missing translations in method isTranslated() in Zend_Translate

Maybe there are more components affected by this issue.


Posted by Eric Jeker (keilnoth) on 2010-05-25T07:38:06.000+0000

This problem is still open in version 1.10.4.

Reproducing it is quite simple, just create a Zend_Form_Element_Select field with a translator enabled and no translation done and add a few values in it.

At line 311 in Zend_Form_Element_Multi, you'll see that this code is called :

<pre class="highlight"> 
if ($translator->isTranslated($value)) {
    return $translator->translate($value);

and Zend_Translate_Adapter->isTranslated() method doesn't log anything before returning false.

So all the values in that select field won't figure in the missing translations log.

Posted by Thomas Weidner (thomas) on 2010-05-25T13:53:26.000+0000

Can you please clearify if it's now a failure or not a failure. Both states are not possible at the same time.

You should also note that logging of untranslated messages depend on the used settings for Zend_Translate. Per default log is NOT enabled because you must attach a log where Zend_Translate can write to.

Posted by Eric Jeker (keilnoth) on 2010-05-25T14:12:41.000+0000

Logging of untranslated messages is activated in my test case.

My opinion is that it's a failure because it works for every other Zend components, examples: input's labels, standard translation, etc... But not in a few cases listed above or in the cloned issue.

I am not talking about optimization or if we should use the isTranslated method. But only about the final result: no log entries for untranslated messages when there should be some.

Posted by Thomas Weidner (thomas) on 2010-05-25T22:38:08.000+0000

As you said that it's working I will detach Zend_Translate from the components being buggy.

Posted by Thomas Weidner (thomas) on 2010-05-25T22:40:23.000+0000

As you said there's a bug I am detaching the "fixed for version 1.8" tag

Posted by Thomas Weidner (thomas) on 2010-05-30T04:18:33.000+0000

Agreed and fixed for Zend_Form_Element and Zend_Dojo_Form_Element with r22322.

Not agreed and no bug for Zend_Validate. Zend_Validate must provide the capability to translate the message constants as also the content.

Not agreed for Zend_Translate. IsTranslated must not throw a notice when checking if a message is translateable.

Posted by Eric Jeker (keilnoth) on 2010-06-07T09:22:33.000+0000

For me, Zend_Validate_Abstract is buggy as well simply because if the getMessages() method is used, like it's done in Zend_Form_Element (line 1368, v1.10), the _createMessage() method in Zend_Validate_Abstract is used to generate the error messages, and in that method, the problem is exactly the same than specified above.

See the code below of the _createMessage() method:

<pre class="highlight"> 
if (null !== ($translator = $this->getTranslator())) {
    if ($translator->isTranslated($message)) {
        $message = $translator->translate($message);
    } elseif ($translator->isTranslated($messageKey)) {
        $message = $translator->translate($messageKey);

The message is not logged because isTranslated() is used.

To re-create the problem, create a Form with a Zend_Form_Element_Text element, setRequired(true) and add a NotEmpty validator. Submit the form with nothing in the field.

Be aware that, if the element already has error messages, then everything work fine because _getErrorMessages() of Zend_Form_Element is used and isTranslated() in not used in that one.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.