DisplayNameFor doesn't lookup resx file despite IStringLocalizer and IHtmlLocalizer working correctly in the Razor page
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
I've got my `Login.cshtml` page
@page
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Localization
@inject IStringLocalizer localizer
@inject IHtmlLocalizer htmlLocalizer
@model LoginModel
@htmlLocalizer["Title"]
TRANSLATES WELL@localizer["Title"]
TRANSLATES WELL[...]
div class="checkbox">
@Html.DisplayNameFor(m => m.Input.RememberMe) //DOESN'T WORK, DOESN'T LOOKUP RESX FILE
In the scaffolded `Login.cshtml.cs` page model there is an attribute [Display] fr the RememberMe property, but this one is not getting translated despite translation being put in the same resource file
///
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
///
[Display(Name = "Remember")] //DOESN'T WORK, DOESN'T LOOKUP RESX FILE
public bool RememberMe { get; set; }
We can see that the structure is correct
[![enter image description here][1]][1]
Resx file itself:
[![enter image description here][2]][2]
This is what gets rendered:
[![enter image description here][3]][3]
[1]: https://i.stack.imgur.com/fbcZP.png
[2]: https://i.stack.imgur.com/5bPlR.png
[3]: https://i.stack.imgur.com/CHJlP.png
### Expected Behavior
Remember gets translated according to the contents of the resource file.
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version
6.0.402
### Anything else?
ASP.NET Core 6
Contributor guide
Assessment
This issue has not been assessed yet.