【发布时间】:2012-03-09 15:10:22
【问题描述】:
我在 ASP.NET MVC 3 表单中使用本地化验证消息。它正确地生成 HTML 像
<input class="inputlong" data-val="true"
data-val-length="Das Feld &quot;Adresse&quot; muss eine Zeichenfolge mit
einer maximalen L&#228;nge von 100 sein."
data-val-length-max="100"
data-val-required="Das Feld &quot;Adresse&quot; ist erforderlich."
id="Address" name="Address" type="text" value=""
/>
当我将 CurrentThread 设置为英语、德语或意大利语 CultureInfo 时,在我的机器上可以正常工作。
但它不适用于另外两台开发人员机器和一台 Windows Server 2008 R2 测试机器(相同的项目,相同的设置:我什至安装了 ASP.NET MVC 3 Tools Update Language包),但我仍然只收到英文验证消息:
<input class="inputnormal input-validation-error" data-val="true"
data-val-length="The field Adresse must be a string with a maximum length of 100."
data-val-length-max="100" data-val-required="The Adresse field is required."
id="Address" name="Adresse" type="text" value=""
/>
我不知道的其他计算机上是否有设置或缺少某些程序集?
【问题讨论】:
-
您是使用默认验证字符串还是有自己的资源?
-
@linkerro 我正在使用默认字符串。我虽然使用本地化显示名称
-
如何设置当前文化?使用 web.config 全球化或其他方式?
-
@archil 我在基本控制器中的每个请求上都设置了当前线程的文化信息(根据用户的选择)。就像我在问题中所说的那样:它在我的开发机器上完美运行。
-
@splattne 在我的回答中,我的意思是在其他开发者和服务器机器上安装语言包。直到安装它也不能在我的开发机器上工作。
标签: asp.net-mvc-3 localization