Displaying messages in different languages in Fluent validation

37 views Asked by At
 public class ExpenditureCreateValidator : AbstractValidator<ExpenditureCreateVM>
 {

     private readonly List<string> _allowedExtensions;

     public ExpenditureCreateValidator()
     {
         _allowedExtensions = new List<string> { ".png", ".jpg", ".jpeg", ".txt", ".pdf", ".docx" };

         RuleFor(file => file.File)
             .NotEmpty().WithMessage("Dosya seçilmelidir.")
             .Must(file => file != null && _allowedExtensions.Contains(Path.GetExtension(file.FileName).ToLowerInvariant()))
             .WithMessage("Bu dosya uzantısı kabul edilemiyor. Dosya yalnızca '.png', '.jpg', '.jpeg', '.txt', '.pdf', '.docx' uzantılarını destekler.");


         RuleFor(x => x.SpendingAmount)
             .NotEmpty().WithMessage("Lütfen bir harcama tutarı giriniz.");

         RuleFor(x => x.SpendingAmount)
             .GreaterThan(0).WithMessage("Harcama tutarı sıfırdan küçük olamaz.");

         RuleFor(x => x.SpendingAmount)
             .Must(BeAValidNumber).WithMessage("Lütfen rakamsal bir değer giriniz.");

     }

     private bool BeAValidNumber(decimal value)
     {
         return value > 0;
     }

 }

It seems like all queries except the part where the user is prompted to enter a numerical value are displayed in Turkish. However, even though you specified that only numerical values should be entered, the prompt appears in English instead of Turkish. How can I fix this? Why is there a difference despite writing the same things?

0

There are 0 answers