Open Closed

How to I Localize Text in Data Annotation of View Models or DTO? #1437


User avatar
0
yuemy@sph.com.sg created

How to I Localize Text in Data Annotation of View Models or DTO?

example below

[Required]
[StringLength(256)]
[Placeholder("Enter Category Code")]
[Display(Name = "Code")]
[PageRemote(
    ErrorMessage = "Code already exists",
    HttpMethod = "get",
    PageHandler = "ValidateCode"
)]
public string CategoryCode { get; set; }

How to localize the Placehoder text, the PageRemote validation error message and the required error message?


2 Answer(s)
  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Hi, you just need add localize text to the localized resource file.

    public class TestDto
    {
        [Required(ErrorMessage = "Code already exists")]
        public string Name { get; set; }
    
        [Required]
        public string Title { get; set; }
    }
    

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11