Very easy question - Translate error text

AlejandroCBA

New member
Joined
Dec 7, 2022
Messages
2
Programming Experience
Beginner
I created the simples project using Microsoft.AspNetCore.Identity.EntityFrameworkCore

I got all working without issues, and I can see the login page without any issue.

The questino is:
When I got the error form validations such as "The Username field is required.", how can I translate this text? (Please note that I am happy translate this manually, I do not need a multilingual project) (I searched in the solution, in the whole database... I am definitly missing something silly here)

Thank you in advance.
 
Can you give us a very small project code so we can see how you've done this? I'm not even sure what web technology you've used
 
Moved this thread to Entity Framework for now assuming that the Identity Core has data annotations for input validation. But if it turns out that the validation is up at the UI level, I'll move this thread again.
 
I'm guessing that you have a RequiredAttribute on that property. If so, I think it's always going to provide that default error message unless you provide one yourself. If you follow the link I provided and read the documentation, which you should already have done, then you'll see their code example of providing a custom error message. That message can be whatever you want in whatever language you want.
 
The link below is for MVC2 data annotation validation message localization, but I have suspicion that the same techniques would still apply in MVC5.


Yup, looks similar:
 
The link below is for MVC2 data annotation validation message localization, but I have suspicion that the same techniques would still apply in MVC5.


Yup, looks similar:
Localised resources is definitely the more professional way to do it and means that you can change messages or add languages without recompiling. If you don't want multiple languages and don't feel the need to be able to change a message without recompiling, providing messages explicitly in the code rather than resource names will be a little less work.
 

Latest posts

Back
Top Bottom