Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Fluent验证中的本地化消息(MVC3)_C#_Asp.net Mvc_Asp.net Mvc 3 - Fatal编程技术网

C# Fluent验证中的本地化消息(MVC3)

C# Fluent验证中的本地化消息(MVC3),c#,asp.net-mvc,asp.net-mvc-3,C#,Asp.net Mvc,Asp.net Mvc 3,在我的MVC 3应用程序中,我使用的是fluent验证 public class AccountModelValidator : AbstractValidator<AccountModel> { public AccountModelValidator() { m.NewPassword).WithMessage(Translator.Data["ConfirmPasswordValidation"]);

在我的MVC 3应用程序中,我使用的是
fluent验证

public class AccountModelValidator : AbstractValidator<AccountModel>
    {
        public AccountModelValidator()
        {
           m.NewPassword).WithMessage(Translator.Data["ConfirmPasswordValidation"]);
        }
    }
公共类AccountModelValidator:AbstractValidator,但我发现我对所有语言都有相同的验证消息

原因是验证器不知道我已经更改了语言

我怎样才能正确地做到这一点


也许我应该使用WithLocalizedMessage,但它仅适用于.resx,当WithLocalizedMessage为所有语言返回相同的值时,很可能尚未设置区域性(这发生在一篇文章中,其中操作处理程序尚未运行)

解决方案是在不同的位置设置区域性:

我希望您实现了一种机制来设置翻译人员的语言环境。您是否在运行时检查了转换器的区域设置?是的,它是正确的,maube我需要用Message编写我自己的方法?我该怎么做?