Tag: asp.net core localization

在单独的项目Asp.net Core MVC中进行本地化

我刚刚升级到Rc2,而以前的工作不再适用。 我在一个单独的项目中有几个resx文件,我使用自定义类来访问数据。 现在运行时出现以下错误: MissingManifestResourceException:找不到适合指定文化或中性文化的任何资源。 确保在编译时将“GarageWeb.Core.CoreResources.resources”正确嵌入或链接到程序集“GarageWeb.Core”中,或者所有所需的附属程序集都是可加载和完全签名的。 编辑:我简化了这一点,并创建了一个控制台应用程序,除了重现错误所需的一切,所以除去了所有内容: https : //github.com/GarageWeb/ResourceTest 这是访问资源的类: public class ResourceService : IResourceService { private readonly ILoggingService _loggingService; private readonly ICoreGlobalResourceService _coreGlobalResources; private readonly ISiteGlobalResourceService _siteGlobalResources; public ResourceService(ILoggingService loggingService, ICoreGlobalResourceService coreGlobalResourceService, ISiteGlobalResourceService siteGlobalResources) { _loggingService = loggingService; _coreGlobalResources = coreGlobalResourceService; _siteGlobalResources = siteGlobalResources; } public string GetGlobalText(string resourceKey, bool includeBrackets = true) { […]

ASP.NET核心模型绑定错误消息本地化

我正在使用ASP.NET Core,并尝试本地化应用程序。 我设法使用新的 asp .net核心资源来本地化控制器和视图,并使用旧资源来本地化错误消息以进行模型validation。 但是,当错误消息未链接到模型字段注释(如“必需”)并且模型绑定的数据不正确时(如预期数字的文本),我收到如下错误,我是无法本地化: “值’abc’对ID无效。” 当我在View为ID属性输入abc ,由于无法对该字段进行模型绑定,并且它在该字段附近显示validation消息,因此说“值’abc’对于ID无效。” 。 这是我正在使用的课程: public class Country : IHasID { public int ID { get; set; } [Required(ErrorMessageResourceType = typeof(L.Val), ErrorMessageResourceName = “NameR”)] [MaxLength(100, ErrorMessageResourceType = typeof(L.Val), ErrorMessageResourceName = “Max”)] public string Name { get; set; } /*Some other properties*/ } 我在互联网上发现的类似问题是针对较旧的asp .net版本,否则无法帮助我解决问题。