PO file localization not working as expected for d

2019-05-20 08:07发布

问题:

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