如何在Asp.Net Core 1.0.0中本地化Display属性?

Yur*_* N. 5 c# localization asp.net-core

我如何NameDisplay属性中进行本地化?例如:

[Display(Name = "Library name")]
public string LibraryName { get; set; }
Run Code Online (Sandbox Code Playgroud)

该属性该怎么办?

fer*_*adz 5

ASP.NET Core 1.0不支持基于新引入的Display属性本地化方法的开箱即用本地化.一种方法是使用ASP.NET Core 1.0之前的方法进行资源文件的本地化.我已经实现了一个简单的演示项目,它显示了如何在这里本地化display属性https://github.com/feradz/ASPNetCoreLocalization/wiki DataAnnotations.resx用于本地化Display属性.

在此方法中,显示名称不能包含特殊字符和空格.例如,显示名称不能,Library name但可以LibraryName

[Display(Name="LibraryName", ResourceType = typeof(Resources.DataAnnotations))]
public string LibraryName { get; set; }
Run Code Online (Sandbox Code Playgroud)