-
-
Notifications
You must be signed in to change notification settings - Fork 128
Error messages do not let us translate the attribute #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As a follow up, there was one more change needed especially for the 'equality' validator: Please note the additional 'options.attribute_tr || ' above, which let us translate the linked attribute. |
Here is an example use of the above changes to support translated attribute: And another for the special case of @Equality with two attributes: |
I have updated the aforementioned proposed changes to avoid prettifying the provided translations: This proposal has the merit of being simple, working now, and compatible with all existing Aurelia applications (if you don't use the 'tr' option, the attributes will just keep not being translated). |
this is now possible- check out the examples in the docs. |
@jdanyow Possible how? What doc are you talking about? Validate.js or Aurelia? Can you provide a link please? |
Validatejs is no longer used. http://aurelia.io/hub.html#/doc/article/aurelia/validation/latest/validation-basics |
If I have a property of my model called "password" to be validated, while I can pass the translated error messages in the options, the attribute never gets translated.
To solve this problem, I have changed on line in validate.js (around line 426):
...
error = v.capitalize(v.prettify(errorInfo.attribute)) + " " + error;
needs to be changed to:
error = v.capitalize(v.prettify(errorInfo.options.tr || errorInfo.attribute)) + " " + error;
While I considered naming the option 'attribute', this would have collided with other uses (e.g. in equality validator). So I went for 'tr', which refers to the i18n.tr() function.
As a result, the attribute name gets properly translated for the user.
The text was updated successfully, but these errors were encountered: