I have ASP.NET Core 3.0 Razor Pages application. Localization works fine as long as all the code is in the main assembly. However if I move my model classes into another library assembly data annotation localization does not work anymore.
How to configure localization in this case? Where to place the .resx files? In the resources folder of the main assembly or somewhere in the library assembly. How should I name the resource files?
public class Message
{
[Display(Name = "ID")]
public int Id { get; set; }
[Display(Name = "Message text")]
public string Text { get; set; }
[Display(Name = "Create date")]
public DateTime Created { get; set; }
}
This Message class is in a different assembly. Here is m current configuration.
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<MessageService, MessageService>();
services.AddLocalization(opts => { opts.ResourcesPath = "Resources"; });
services.AddRazorPages()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
}