This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Description
Hello, Do you have any example on localizing DisplayAttribute or similar? i tried creating my own localized attribute but it seems you can't proper DI into attribute classes, here is what i tried:
public sealed class LocalizedDisplayAttribute : Attribute
{
protected IJsonStringLocalizer StringLocalizer;
public LocalizedDisplayAttribute(string displayName)
{
StringLocalizer = HttpContextHelper.HttpContext.RequestServices.GetService<IJsonStringLocalizer>();
DisplayName = displayName;
}
public string DisplayName
{
get
{
return StringLocalizer[DisplayName];
}
set
{
}
}
}
unfortunately it always returns null service to me, tried using httpcontextaccessor, direct injection and what not..
if anyone have done this already please help.