2

In my MVC 3 application I am using fluent validation.

public class AccountModelValidator : AbstractValidator<AccountModel>
    {
        public AccountModelValidator()
        {
           m.NewPassword).WithMessage(Translator.Data["ConfirmPasswordValidation"]);
        }
    }

For localization I am using an example that I have found from here, but I have found that I have the same validation message for all languages.

The reason is that validator doesn't know that I have change the language.

How can I correctly do this?

Maybe I should use WithLocalizedMessage but it works only with .resx

Erik Oppedijk
  • 3,496
  • 4
  • 31
  • 42
revolutionkpi
  • 2,632
  • 10
  • 45
  • 84

1 Answers1

1

When the WithLocalizedMessage returns the same value for all languages, most likely the culture isn't set yet (this happens on a POST, where the action handlers haven't run yet)

Solution is to set the culture in a different location: Best place to set CurrentCulture for multilingual ASP.NET MVC web applications

Community
  • 1
  • 1
Erik Oppedijk
  • 3,496
  • 4
  • 31
  • 42