在Asp.Net Core中使用可移植对象(Orchard Core .po)定位Display(Name =。“ ..”)数据注释属性时出现问题

时间:2019-02-26 17:40:17

标签: asp.net-core localization orchardcms asp.net-core-localization

Screenshot:我正在使用Orchard Core框架在ASP.NET Core(2.1.1)应用程序中使用可移植对象(PO​​)文件。我遵循了https://docs.microsoft.com/en-us/aspnet/core/fundamentals/portable-object-localization?view=aspnetcore-2.2中的说明。我在实体中本地化[Display(Name =“ ...”)]数据注释属性时遇到麻烦。相同的属性在Enums中可以正常工作。验证数据注释属性可以正常工作。

public class MyClassDto {
    [Display(Name = "Name")]
    [Required(ErrorMessage = "Name is required")]
    [StringLength(100, ErrorMessage = "Cannot exceed {1} characters")]
    public string Name { get; set; }

    [Display(Name = "Context Type")]
    public EntityType TargetEntityTypeID { get; set; }   }

public enum EntityType
{
    [Display(Name = "Deal")]
    Deal = 1,
    [Display(Name = "Company")]
    Company = 2,
    [Display(Name = "Contact")]
    Contact = 3
}
/* ru.po:*/
msgid "Name"
msgstr "Имя"

msgid "Name is required"
msgstr "Введите Имя"

msgid "Context Type"
msgstr "Тип Контекста"

msgid "Deal"
msgstr "Сделка"

msgid "Contact"
msgstr "Контакт"

msgid "Company"
msgstr "Компания"

msgid "Template"
msgstr "Шаблон"

msgid "Create"
msgstr "Создатъ"

msgid "Cannot exceed {1} characters"
msgstr "Введите не более {1} символов"

msgid "Cancel"
msgstr "Отменить"

msgid "Create New {0}"
msgstr "Создатъ {0}"

当我在查询字符串中添加&culture = ru 时,实体类中除DisplayAttribute之外的所有内容似乎都已翻译:Screenshot

是否可以使用ASP.Net Core 2.1.1中的PO本地化在实体类中本地化DisplayAttribute?

0 个答案:

没有答案