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

1 回答 1

4

你在谈论本地化。检查这个

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; }
于 2012-05-07T13:46:51.543 回答