diff --git a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorOfTAttribute.cs b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorOfTAttribute.cs
index 25337574ee..130142df57 100644
--- a/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorOfTAttribute.cs
+++ b/src/Microsoft.AspNet.Mvc.DataAnnotations/DataAnnotationsClientModelValidatorOfTAttribute.cs
@@ -52,16 +52,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
throw new ArgumentNullException(nameof(modelMetadata));
}
- var displayName = modelMetadata.GetDisplayName();
if (_stringLocalizer != null &&
- !string.IsNullOrEmpty(Attribute.ErrorMessage) &&
- string.IsNullOrEmpty(Attribute.ErrorMessageResourceName) &&
- Attribute.ErrorMessageResourceType == null)
+ !string.IsNullOrEmpty(Attribute.ErrorMessage) &&
+ string.IsNullOrEmpty(Attribute.ErrorMessageResourceName) &&
+ Attribute.ErrorMessageResourceType == null)
{
- return _stringLocalizer[displayName];
+ return _stringLocalizer[Attribute.ErrorMessage];
}
- return Attribute.FormatErrorMessage(displayName);
+ return Attribute.FormatErrorMessage(modelMetadata.GetDisplayName());
}
}
}
diff --git a/test/WebSites/LocalizationWebSite/Models/User.cs b/test/WebSites/LocalizationWebSite/Models/User.cs
index cf4daa9b55..4ecd4f0770 100644
--- a/test/WebSites/LocalizationWebSite/Models/User.cs
+++ b/test/WebSites/LocalizationWebSite/Models/User.cs
@@ -7,7 +7,7 @@ namespace LocalizationWebSite.Models
{
public class User
{
- [MinLength(4, ErrorMessage = "Name")]
+ [MinLength(4, ErrorMessage = "NameError")]
public string Name { get; set; }
public Product Product { get; set; }
diff --git a/test/WebSites/LocalizationWebSite/Resources/LocalizationWebSite.Models.User.fr.resx b/test/WebSites/LocalizationWebSite/Resources/LocalizationWebSite.Models.User.fr.resx
index 01c1eacfd4..f3563679cd 100644
--- a/test/WebSites/LocalizationWebSite/Resources/LocalizationWebSite.Models.User.fr.resx
+++ b/test/WebSites/LocalizationWebSite/Resources/LocalizationWebSite.Models.User.fr.resx
@@ -117,7 +117,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
Nom non valide. Longueur minimale de nom est 4
\ No newline at end of file