Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
493 views
in Technique[技术] by (71.8m points)

localization - ASP.NET MVC 3 localized validation messages work on my machine, but not on server

I'm using localized validation messages in a ASP.NET MVC 3 form. It correctly generates HTML like

<input class="inputlong" data-val="true" 
   data-val-length="Das Feld &amp;quot;Adresse&amp;quot; muss eine Zeichenfolge mit
                  einer maximalen L&amp;#228;nge von 100 sein." 
   data-val-length-max="100" 
   data-val-required="Das Feld &amp;quot;Adresse&amp;quot; ist erforderlich." 
   id="Address" name="Address" type="text" value="" 
/>

This works fine on my machine when I set my CurrentThread to an English, German or Italian CultureInfo.

But it doesn't work on two other developer machines and a Windows Server 2008 R2 test machine (same project, same setup: I've even installed the ASP.NET MVC 3 Tools Update Language Packs), but I still get only the English validation messages:

 <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=""
 />

Are there settings or some missing assemblies on the other computers I am not aware of?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You may have to install .net framewok language pack. For example, on my machine validation messages would not show up in German until I installed German language pack.

Required attribute is not part of asp.net-mvc but more general DataAnnotations, so language pack should help.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...