Sunday, December 27, 2009

Re: Localization for Model validation messages

i wouldnt copy it exactly 1:1

translations should never be just "Minimum length of 8 characters"
then you'd need the same text for all other 9999999 different
character lenghts

better to use sprintf(__(text, true), var1, var2, ..) with %s etc


On 27 Dez., 10:47, Walther <waltherl...@gmail.com> wrote:
> Check here:http://book.cakephp.org/view/133/Multiple-Rules-per-Field
> (at the bottom) for the recommended method of doing it.
>
> On Dec 26, 10:55 am, si-mon <sijumo...@gmail.com> wrote:
>
> > Thanks John. Thanks Euromark. Really helpful...
>
> > On Dec 25, 9:55 pm, John Andersen <j.andersen...@gmail.com> wrote:
>
> > > I can't agree, as I prefer to have the model be concerned with model
> > > things (data, retrieval, saving, validation, etc.), and the view
> > > concerned with presenting the data and the related error messages,
> > > including the localization!
>
> > > Usually I only have one form in which data for a specific model is
> > > entered, so the adding a new rule and forgetting to add the
> > > localization in the form, does not become an issue! Also, a change is
> > > always planned - what to add, what to change, etc.
>
> > > But each of us use the technique which we are comfortable with :)
> > >    John
>
> > > On Dec 25, 4:32 pm, euromark <dereurom...@googlemail.com> wrote:
>
> > > > i dont like the form-way
> > > > it is quite redundant - if you add a new rule you might forget
> > > > one or two views which would not be helpful
>
> > > > having it all together in the model is in my opinion a cleaner
> > > > approach :)
>
> > > > On 25 Dez., 12:32, John Andersen <j.andersen...@gmail.com> wrote:
>
> > > > > Use the form helpers option for the input fields! Look at:http://book.cakephp.org/view/198/options-error
>
> > > > > Thus you localize in the view - example:
>
> > > > > echo $form->input(
> > > > >    'email',
> > > > >    array(
> > > > >       'label' => __('e-mail address',true),
> > > > >       'error' => array('users_email_rule' => __
> > > > > ('users_email_rule',true) )
> > > > >    )
> > > > > ) ;
>
> > > > > Observe the 'error' option! Here I use it to convert the validation
> > > > > message into the language that the user is viewing the form.
>
> > > > > Enjoy,
> > > > >    John
>
> > > > > On Dec 24, 7:39 pm, si-mon <sijumo...@gmail.com> wrote:
>
> > > > > > Hi All,
>
> > > > > > Is there a way to use localization for validation messages in the
> > > > > > Model $validate array?
>
> > > > > > eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
> > > > > > 'message'=>'Name is mandatory' ));
>
> > > > > > I need the message 'Name is mandatory' in five different languages.
>
> > > > > > In other words: How can we use functions like __('message') like
> > > > > > functions in model?
>
> > > > > > Please help me. Thanks.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate