c# - PO 文件本地化无法按预期用于数据注释

标签 c# asp.net-core-2.0 po

我在我的 asp.net 核心应用程序中使用了 Orchard Localization。

Startup.cs

services.AddPortableObjectLocalization(options => options.ResourcesPath = "Resources");
services
.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();

模型.cs

[Display(Name = "First Name")]
[Required(ErrorMessage = "Customer first name required")]
public string CustomerFirstName { get; set; }

en.po(包含英文翻译)

msgid "Customer first name required"
msgstr "Customer first name required"

no.po(包含挪威语翻译)

msgid "Customer first name required"
msgstr "Fornavn mangler"

英文请求url

Home/HomeRequest/?cid=40&culture=en

挪威语请求 url

Home/HomeRequest/?cid=11&culture=no

我首先输入英文网址并检查了所需的验证,英文本地化验证完美触发。然后我将 cid 和 culture 的值更改为挪威语,并检查了英语本地化而不是挪威语的验证验证。

如何根据locale获取数据注解校验?

最佳答案

问题是 OrchardCore.Localization.Core nuget 包中的错误,现在已修复。将您的软件包更新到版本 1.0.0-beta3-71025 或更高版本以解决此问题。
你可以找到问题线程 here

关于c# - PO 文件本地化无法按预期用于数据注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52307486/

相关文章:

npm - 如何在 Visual Studio 2017 中更新 React npm 包

testing - 在 VS2017 中使用 xUnit 测试 .NET Core 2.0 类库时如何设置 ASPNETCORE_ENVIRONMENT

translation - po 翻译文件 : what are automatic comments for?

cakephp - 如何从 .pot 文件获取 .po 文件

java - 避免 .properties 文件 GNU Gettext java

c# - C#/Perl 连接中的套接字缓冲区溢出

c# - Azure 存储 SAS 身份验证失败

c# - 如何使用 POSTMAN 模拟 Webhook 并在 Action 中接收它

c# - 如何使用 ASP.NET Core 2.0 存储和恢复 cookie?

c# - 具有多个 STA 线程的 Wpf 应用程序仍然阻塞用户界面