Hi Ralf, I have created a JIRA issue for us to track and examine:
http://framework.zend.com/issues/browse/ZF-1998 Thanks for the report! Best regards, Darby Ralf Kramer wrote: > Hi, > > I tried to customize the message of Zend_Validate_EmailAddress, it works > quite well, but I cant translate the messages that are added by > Zend_Validate_Hostname in my $validators array. > > Sample: > $validators = array( > 'user_email' => array( > 'EmailAddress', > 'messages' => array( > array( > Zend_Validate_EmailAddress::INVALID => > "'%value%' ist keine gültige E-Mail-Adresse", > > Zend_Validate_EmailAddress::INVALID_HOSTNAME => > "'%hostname%' ist kein gültiger Hostname. Bitte > prüfen Sie Ihre E-Mail-Adresse '%value%'", > > Zend_Validate_EmailAddress::INVALID_MX_RECORD => > "'%hostname%' kein MX Record gefunden '%value%'", > > Zend_Validate_EmailAddress::DOT_ATOM => > "'%localPart%' ungültiges Format (dot-atom)", > > Zend_Validate_EmailAddress::QUOTED_STRING => > "'%localPart%' ungültiges Format", > > Zend_Validate_EmailAddress::INVALID_LOCAL_PART > => "'%localPart%' ungültiges Format '%value%'", > ) > ) > ) > ); > > When $user_email == "a" I get this messages: > ["user_email"] => array(3) { > [0] => string(81) "'a' ist kein gültiger Hostname. Bitte prüfen Sie Ihre > E-Mail-Adresse '[EMAIL PROTECTED]'" > [1] => string(60) "'a' does not match the expected structure for a DNS > hostname" > [2] => string(82) "'a' appears to be a local network name but but local > network names are not allowed" > } > > So, there are two messages which are not translated, and I don’t know how to > translate them in my $validators array. Is there a way to achieve this? > > If not, we should imho contemplate to ensure that each Zend_Validate_XXX > class must gain access to all possible messages that could be added to the > $messages array > > Though Bill explained, in a recent posting, that developers might use > $input->getErrors(); to customize their messages, I'd prefer to translate > the messages using the MESSAGES > metacommand of Zend_Filter_Input. Having it all defined in one place, allows > for instance to pass the $validator array to the view, where it could be used > for AJAX and other Javascript operations. It would also be somewhat more > 'straight' if there is no exceptional rule bundled to the MESSAGES > metacommand > > I am not sure whether the proposals Zend_Validate_Builder, > Zend_Filter_Builder will solve this issue. Actually I am not even sure > whether it is an issue... ;-) > > Best regards > /Ralf > > > > >
