2

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?

Suvethan Nantha
  • 2,404
  • 16
  • 28
  • Do you reach any solution for this? – dev-masih Mar 26 '19 at 16:11
  • Nope, but I found a way, earlier what I did was I appended the culture to the url programically, but rather than doing that now I'm appending the culture at the url at starting pointing itself and it works fine according to my requirement. but I don't know how to programically handle it yet. – Suvethan Nantha Mar 27 '19 at 04:45
  • There is a bug in Orchard Localization nuget that fixed, you can update it. – dev-masih Mar 27 '19 at 06:38

1 Answers1

0

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

dev-masih
  • 4,188
  • 3
  • 33
  • 55