netceteragroup / valdr

A model centric approach to AngularJS form validation
http://netceteragroup.github.io/valdr/
MIT License
153 stars 43 forks source link

validation message translation #117

Closed HASSANDL closed 7 years ago

HASSANDL commented 7 years ago

hello, thanks for this plugin. below code work without error, but email.required error display 'message.required'.

$translateProvider.translations('fa',
        {
            'message': {
                'required': 'وارد کردن فیلد {{fieldName}} الزامی است.',
                'size': 'حداقل {{min}} کاراکتر و حداکثر {{max}} کاراکتر',
            },
            'Person': {
                'email': 'پست الکترونیکی',
                'password': 'کلمه عبور',
            },
        }
    );

    $translateProvider.preferredLanguage('fa');

// Validation
    valdrProvider.addConstraints(
        {
            'Person': {
                'name': {
                    'required': {
                        'message': 'message.required'
                    }
                },
                'email': {
                    'required': {
                        'message': 'message.required'
                    },
                    'email': {
                        'message': "لطفاً پست الکترونیکی خود را به درستی وارد نمایید"
                    }
                },
                'password': {
                    'required': {
                        'message': 'message.required'
                    },
                    'size': {
                        'min': 6,
                        'max': 20,
                        'message': 'message.size'
                    },
                },
            }
        }
    );
marcelstoer commented 7 years ago

You stand a much better chance of getting noted if you put together a self-contained test case on https://plnkr.co/ or https://jsfiddle.net/.

HASSANDL commented 7 years ago

I use exactly example. but not showing message error, only show "'message.required'".

gpeshans commented 7 years ago

Your solution seems fairly ok to me. I prepared a working example here, using the same configuration you provided above and its working fine. Maybe you are missing something elsewhere. You can try it out and if you have any other questions, don't hesitate to ask.

marcelstoer commented 7 years ago

No feedback from OP in a month -> closing.