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

Issue Type: Improvement Created: 2009-08-06T08:02:50.000+0000 Last Updated: 2010-03-02T17:19:42.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Stijn Huyberechts (huyby) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

Related issues: Attachments:


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.


Posted by Thomas Weidner (thomas) on 2009-08-23T14:11:07.000+0000

Feature implemented with r17784

Posted by Paul Hanssen (paul.hanssen) on 2010-03-01T23:40:09.000+0000


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

Posted by Thomas Weidner (thomas) on 2010-03-02T13:39:43.000+0000

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.

Posted by Paul Hanssen (paul.hanssen) on 2010-03-02T17:19:42.000+0000

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

Cheers, Paul

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.