PO file localization not working as expected for data annotation

断了今生、忘了曾经 提交于 2019-12-14 02:19:03

问题


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 (contains English translations)

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

no.po (contains Norwegian translation)

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

Request url for english

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

Request url for norwegian

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

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?


回答1:


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



来源:https://stackoverflow.com/questions/52307486/po-file-localization-not-working-as-expected-for-data-annotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!