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.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 20, 2025, 18:00