PO文件本地化无法按预期方式进行数据注释 [英] PO file localization not working as expected for data annotation

查看:174
本文介绍了PO文件本地化无法按预期方式进行数据注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net核心应用程序中使用过Orchard Localization.

I have used Orchard Localization in my asp.net core application.

Startup.cs

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

model.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"

编号(包含挪威语翻译)

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

请求英语的网址

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

请求挪威语的网址

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

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

I first entered english url and checked the required validation, validation for english localization fired perfectly. Then I changed value of cid and culture to norwegian and checked the validation validation fires with english localization not in norwegian.

如何根据语言环境获得数据注释验证?

How to get the data annotation validation according to the locale?

推荐答案

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

The problem was a bug in OrchardCore.Localization.Core nuget package and it's fixed now. update your package to version 1.0.0-beta3-71025 or above to fix this problem.
you can find the issue thread here

这篇关于PO文件本地化无法按预期方式进行数据注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆