Knockout-Contrib / Knockout-Contrib/Knockout-Validation
Locale not loading on errors.showAllMessages(true)
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 366
- PR merge metrics
- No merged PRs in 30d
Description
Hi, i think there's a bug related to the locale settings when you call the method showAllMessages().
I'm using es-ES locale in one of my apps with ko.validation, but when i call this method, it wont show the messages in spanish as it should, but in english, ignoring locale settings. My code looks like this:
``` js
ko.validation.locale("es-es");
ko.validation.init({
registerExtenders: true,
messagesOnModified: true,
insertMessages: true,
parseInputAttributes: true,
errorElementClass: "has-error",
errorMessageClass: "help-block",
decorateInputElement: true
}, true);
self.saveUser = function () {
var errors = ko.validation.group(self, { deep: true });
if (errors().length === 0) {
var user = ko.toJSON(self);
dataModel.putUser(user)
.done(function(result) {
alert("User saved");
})
.fail(self.onUserCreationError);
} else {
errors.showAllMessages(true);
}
}
```
messages will display if there are errors in the saveUser() call, but they wont be in the language it was set in the ko.validation.locale
EDIT:
Looking at ko.validation code, i noticed this messages are just there, in each of the validations, that is why they are not showing using the locale settings.
Contributor guide
Research direction
Start by tracing the ko.validation.locale setup through the errors.showAllMessages(true) path and compare it with the validation message definitions mentioned in the issue. Confirm the behavior with the provided saveUser example; done means messages displayed after showAllMessages use the selected Spanish locale rather than English.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100