1

Screenshot: I am using Portable Object (PO) files in an ASP.NET Core(2.1.1) application with the Orchard Core framework. I followed the instructions in https://learn.microsoft.com/en-us/aspnet/core/fundamentals/portable-object-localization?view=aspnetcore-2.2. I am having trouble localizing [Display(Name="...")] data annotation attribute in my entities. The same attribute works fine in Enums. Validation data annotation attributes work fine.

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

When I add &culture=ru to query string, everything except the DisplayAttribute in the entity class seems to be translated:Screenshot

Is there a way to localize DisplayAttribute in entity classes using PO localization in ASP.Net Core 2.1.1?

Sonya V.
  • 11
  • 3

0 Answers0