Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
HTML form input field tag helpers are rendered useless for many developers by the lack of default localization and globalization for the data-annotations they generate.
Using them in an non-English application causes the display of English validation messages to the user, which is a no-go.
Moreover, culture sensitive inputs do not work.
Have a decimal number input field and an application in French. The number will be output in the input field with a comma as decimal separator (default for french culture). But submitting the form will be blocked by the field considered filled with a value which is "not a number", because the data annotation validation expect a dot for the decimal separator. Complying with this still does not work, because the model binder on server side then rejects the value because it expects a comma as decimal separator.
This causes us to avoid using input field tag helpers entirely.
Describe the solution you'd like
Have default globalization and localization available for data-annotation.
Some workarounds:
- Follow the globalization & localization documentation. That means every project has to supply its own translations and globalization of the default data-annotations. There is no value in having to do this over and over.
- Do not use these tag helpers and write your own HTML instead. Using HTML 5 validation attributes ends up being far better for us than using tag helpers. That outputs messages in the browser default interface language, which suits our users far better than hard-coded English messages. And that allows us to avoid the culture sensitive input field trouble by setting them to type text and validating their value through the pattern attribute. (Meaning providing our own message in the title attribute, but that is still better than having to localize all the other cases too.)
Additional context
This is a regression compared to the situation with MVC in .Net Framework, in which data-annotations generated by default HTML helpers (InputFor and the like) were having packages per languages providing default localization and globalization, like this one. (Or was it this or this? Anyway, it was available.)
Related issues:
- Provide localization for default error messages in System.ComponentModel.Annotations: closed as won't fix, no plan to do it.
- Localize standard DataAnnotations in ASP.NET Core MVC #33073: seems closed as "it works" while it does not, it is not done, there is no default globalization available as far as I know. Or maybe the closer considers having the possibility to provide our own one is enough, without stating it explicitly, so that would be another "won't fix".