diff --git a/src/Orchard/Mvc/DataAnnotations/LocalizedModelValidatorProvider.cs b/src/Orchard/Mvc/DataAnnotations/LocalizedModelValidatorProvider.cs index cdb6d8765..436c49183 100644 --- a/src/Orchard/Mvc/DataAnnotations/LocalizedModelValidatorProvider.cs +++ b/src/Orchard/Mvc/DataAnnotations/LocalizedModelValidatorProvider.cs @@ -22,13 +22,14 @@ namespace Orchard.Mvc.DataAnnotations { var localizedAttributes = new List(); // overriden messages have their localization in the scope of the class they are applied to - var tContainer = new Lazy(() => LocalizationUtilities.Resolve(context, metadata.ContainerType.FullName)); + var tContainer = new Lazy(() => LocalizationUtilities.Resolve(context, (metadata.ContainerType ?? metadata.ModelType).FullName)); foreach (var attribute in attributes) { Func localizedAttribute; // default translations use the attribute's scope, e.g., Orchard.Mvc.DataAnnotations.LocalizedRequiredAttribute - var tProvider = new Lazy(() => LocalizationUtilities.Resolve(context, attribute.GetType().FullName)); + var localAttribute = attribute; + var tProvider = new Lazy(() => LocalizationUtilities.Resolve(context, localAttribute.GetType().FullName)); var validationAttribute = attribute as ValidationAttribute;