2012-05-07 67 views
2

我有這個代碼爲我的實體。實體框架數據註釋和多語言

我不知道是否有一種方法可以根據用戶選擇的語言,用一些對資源文件的引用替換硬編碼文本。

public class Applicant 
    { 
     [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 
     public int ApplicantID { get; set; } 

     [Required(ErrorMessage = "Name is required")] 
     [StringLength(20, MinimumLength = 3, ErrorMessage = "Name should not be longer than 20 characters.")] 
     [Display(Name = "First and LastName")] 
     public string Name { get; set; } 

回答

4

你說的是這個Localization.Check

http://adamyan.blogspot.com/2010/02/aspnet-mvc-2-localization-complete.html

[Display(Name = "Email", ResourceType = typeof(Localization))] 
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(Localization))] 
[Email(ErrorMessageResourceName = "EmailFormatError", ErrorMessageResourceType = typeof(Localization))] 
public string Email { get; set; } 
+0

我愛的例子,但我沒有做MVC,只是web表單,它改變什麼? –