sdlins / yii2-at-least-validator

Makes one or more attributes mandatory inside a set of attributes.
Apache License 2.0
28 stars 19 forks source link

use i18n message labels #7

Closed squio closed 7 years ago

squio commented 8 years ago

This change uses the i18n module when enabled so attribute labels are returned in the localized version.

NOTE this does NOT translate the massage string itself. A quick work around is to add he following to the rules declaration:

['body', AtLeastValidator::className(), 'in' => ['body', 'uploadfile'],
            'message' => Yii::t('app', 'You must fill at least {min} of the attributes {attributes}.')],

And then in your app messages (example for Dutch):

'You must fill at least {min} of the attributes {attributes}.' => 
     'Je moet minimaal {min} van de attributen {attributes} opgeven.'

This can be added to the documentation or even add a translation file for this module.

sdlins commented 7 years ago

Hi @squio. Thank you so much for your contribution!

About the docs/translation, when you have some time maybe you could open a new issue (or multiple) and do it yourself. It would be nice.