ZF-7508: Zend_Translate::isTranslated() should not log if untranslated


I've noticed that the isTranslated() method also adds an entry to the log is the messageId is not found. But is seems to be more convenient when only the translate() method would log an untranslated method. Now I'm getting entries in my log when I was only trying to find out if a messageId exists.

Zend_Translated::isTranslated() should only return a Boolean, no more, no less.


Feature implemented with r17784


This has caused an issue for me.

We log all our untranslated messages to a .php file that is then run through POEdit.

This has proven really useful for translating validation error messages generated via {{Zend_Filter_Input}}; newer validation errors are dumped to the .php file when the developer triggers them while writing the code.

However, this behaviour is no longer working as of 1.10.0 ... refer to this code in {{Zend_Filter_Input}} line 766:

{{ protected function _getNotEmptyMessage($rule, $field) { $message = $this->_defaults[self::NOT_EMPTY_MESSAGE];

    if (null !== ($translator = $this->getTranslator())) {
        if ($translator->isTranslated($message)) {
            $message = $translator->translate($message);
        } elseif ($translator->isTranslated(self::NOT_EMPTY_MESSAGE)) {
            $message = $translator->translate(self::NOT_EMPTY_MESSAGE);

... etc ...


If the translated (full) error message is not found, then translate the (generic) error key.

But since the {{isTranslated}} function is no longer logging missing translations, the untranslated validation message is never translated & never logged, meaning that you will always have to manually add validation messages to the translation file.

Or worse, the generic translation for "{{isEmpty}}" (in this case) will appear in the place of every new validation message.

It would be really great to get this facility back :)

Cheers, Paul

All validation messages are available as already pre-translated resource files as with ZF 1.10. So there is no need to do the described workflow for validation errors.

Note that when there is no translated message even Zend_Translate will return the original message.

From point of implementation isTranslated just request IF a translation can be translated... it should NEVER throw a notice/warning/error. We shold and will not reintegrate this errorous behaviour.

But with existing functionality it is also possible to check translations... you just need to change the model which does translation. Add a log entry when original error is the same as the translated error.

Thanks for the reply ... I've just seen your blog entry on the subject:


Cheers, Paul