gpt4 book ai didi

entity-framework - Entity Framework 数据注释和多语言

转载 作者:行者123 更新时间:2023-12-04 18:21:52 25 4
gpt4 key购买 nike

我的实体有此代码。

我想知道是否有一种方法可以根据用户选择的语言将硬编码文本替换为对资源文件的一些引用。

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; }

最佳答案

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

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; }

关于entity-framework - Entity Framework 数据注释和多语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10483179/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com