Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Localization of CompareAttribute should be localized #3527

Closed
Anderman opened this issue Nov 11, 2015 · 3 comments
Closed

Localization of CompareAttribute should be localized #3527

Anderman opened this issue Nov 11, 2015 · 3 comments

Comments

@Anderman
Copy link

The
_stringLocalizer[Attribute.ErrorMessage,displayName, GetOtherPropertyDisplayName(context)
Is missing
remarks

  • To be consistent: Displayname and OtherPropertyName should also be localized

setup test

        [Compare(nameof(Password))]
        [Display(Name = "Email")]
        public string Email { get; set; }

        [Compare(nameof(Password), ErrorMessage = "{0} en {1} komen niet overeen(NL)")]
        [Display(Name = "PwPassword", ResourceType = typeof(loc))]
@NTaylorMullen
Copy link
Member

This overlaps a bit with #3518

@Anderman
Copy link
Author

Yeah, I totally agree that display name should be localized by the new _stringlocalizer

@Eilon
Copy link
Member

Eilon commented Dec 31, 2015

Looks like this was fixed along with all the other attributes, here's the current code:

public override string FormatErrorMessage(string name)
{
var displayName = ValidationContext.ModelMetadata.GetDisplayName();
return string.Format(CultureInfo.CurrentCulture,
ErrorMessageString,
displayName,
GetOtherPropertyDisplayName(ValidationContext, this));
}

@Eilon Eilon closed this as completed Dec 31, 2015
@Eilon Eilon added this to the 6.0.0-rc2 milestone Dec 31, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants