I need to localize a data annotation error message in the Blazor. I have created a SharedResource class, but the validation summary returns the resource's key instead of the resource's value.
@page "/"
@using WebApplication1.Data
@using WebApplication1.Resources
@inject LocService SharedLocalizer
@SharedLocalizer.GetLocalizedHtmlString("Title")
<EditForm Model="@Movie" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<InputText id="Title" bind-Value="@Movie.Title" />
<button type="submit">Submit</button>
</EditForm>
@functions {
private Movie Movie = new Movie();
private void HandleValidSubmit()
{
Console.WriteLine("OnValidSubmit");
}
}
public class Movie
{
public int Id { get; set; }
[Required(ErrorMessage = "titleRequired")]
[EmailAddress]
[Display(Name = "titleRequired")]
public string Title { get; set; }
}