2

I have a Zend_Form_Element_Select object, and about 3k select options. When the customer asked me to look further into optimization possibilities, I did some debug tracing, and noticed, that there were more than 3k calls to Zend_Form_Element_Multi->_translateValue and a little less to Zend_Form_Element_Multi->_translateOption . I found the option to set $elem->setDisableTranslator(true), which took care of these translations, for which I had no need. But the problem now is, that the error messages are no longer translated.

What I would like to know is, if there is a way to not translate values and options, but translate Validator messages?

I tried this:

foreach($operators->getValidators() as $val){
        $val->setDisableTranslator(false);
    }

but to no avail.

Janis Peisenieks
  • 4,938
  • 10
  • 55
  • 85

1 Answers1

2

I don't see any option within the element classes so the simple solution would be extending the Zend_Form_Element_Select class with your own. Then you can override the _translateOptions method as follows

class My_Form_Element_Select extends Zend_Form_Element_Select {

    protected function _translateOption($option,$value) {
        // or add more logic here
        return false;
    }
}

Furthermore, you can set some additional logic and options for this scenario, i.e. turn on/off translation for options.

If you want to eliminate this calls all together you will have to override the getMultiOption() or getMultiOptions() which are calling _translateOption().

Adrian World
  • 3,118
  • 2
  • 16
  • 25