From 1a0c0b75e4f26137dba8679514bb3bcabe02ed81 Mon Sep 17 00:00:00 2001 From: ldhertert Date: Fri, 2 Dec 2011 16:02:32 -0800 Subject: [PATCH] #18156: Fixing localized attributes when using a metadata class Work Item: 18156 --HG-- branch : 1.x --- .../Mvc/DataAnnotations/LocalizedModelValidatorProvider.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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;