How to add ViewModel localization to Blazor?

后端 未结 2 958
遇见更好的自我
遇见更好的自我 2021-01-07 03:54

We all know the lack of ViewModel localization in Blazor

Today i tried many ways, and i came up with a good method to be followed to apply localization

2条回答
  •  长发绾君心
    2021-01-07 04:51

    DataAnnotations validation is probably not the best way to achieve this as the validation logic is tied to the class, and as you saw in your own answer, it means a lot of duplication.

    FluentValidation provides an answer since it actually has built-in localization support (it also has built-in messages in many languages for default validations!).

    I created a demo project on GitHub to show how it works.

    As you can see this solution is a lot simpler.

提交回复
热议问题