Matthew,
How does this work for 'INVALID' that appears in EmailAddress and Date? Or
'STRING_EMPTY' that appears in Alnum, Alpha, and Digits?
Jim
Matthew Weier O'Phinney-3 wrote:
>
> -- Dividy <[EMAIL PROTECTED]> wrote
> (on Saturday, 02 February 2008, 03:19 PM -0800):
>> For my first post on this nice forum, could someone explain me in details
>> how to translate the error messages of a zend_form validation ?
>>
>> I tried much thing but none work.
>
> You'll need to do several things.
>
> First, for each validator you use, determine what the various error
> codes are -- you can do this by looking at the values of the validator's
> class constants. For instance, 'Zend_Validate_NotEmpty' defines the
> constant Zend_Validate_NotEmpty::STRING_EMPTY to 'stringEmpty'.
>
> Armed with that list, create translations for one of the translation
> adapters supported by Zend_Translate. If you were using, for instance,
> the 'array' adapter, you could do this:
>
> <?php
> // translations.php
> return array(
> 'stringEmpty' => 'Please fill in this value',
> ...
> );
>
> Then, create your translate object:
>
> $translations = include 'path/to/translations.php';
> $translate = new Zend_Translate('array', $translations, 'en');
>
> And pass the translation adapter to your form:
>
> $form->setTranslator($translate->getAdapter());
>
> And that's all there is to it. The above defines english translations,
> but you can do whatever language you want; refer to the Zend_Translate
> manual for more information on creating these.
>
> --
> Matthew Weier O'Phinney
> PHP Developer | [EMAIL PROTECTED]
> Zend - The PHP Company | http://www.zend.com/
>
>
--
View this message in context:
http://www.nabble.com/Zend_Form-and-validation-language-tp15248574s16154p15269233.html
Sent from the Zend Framework mailing list archive at Nabble.com.