dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.38k stars 10k forks source link

Display name of enum no longer gets localized in .NET 3.0 #16854

Closed jaska45 closed 4 years ago

jaska45 commented 4 years ago

I have an enum

public enum Sport
{
    [Display(Name = "Soccer")]
    Soccer,

    [Display(Name = "Ice hockey")]
    IceHockey,

    [Display(Name = "Basketball")]
    Basketball
}

Then I use the following code in a view to populate a combo box:

<select class="form-control" asp-for="Sport" asp-items="Html.GetEnumSelectList<Sport>()">
</select>

Finally I added a localized .resx file: Models.Sport.fi.resx

This works in ASP.NET 2.2 but not 3.0

You can find a sample here

jaska45 commented 4 years ago

This was my mistake. The namespace in 3.0 sample was incorrect. The localization works. You can close this.