Base solution for your next web application
Open Closed

How to implement localization for predefined error message #107


User avatar
0
lcyhjx created

Hi,

Please see following scenario: I mark a field as [required] for a service input, then I invoke this service but do not pass the value of the required field. Then get following response:

{
   "success": false,
   "result": null,
   "error":    {
      "code": 0,
      "message": "Your request is not valid!",
      "details": null,
      "validationErrors": [      {
         "message": "The EstimateStartTime field is required.",
         "members": null
      }]
   },
   "unAuthorizedRequest": false
}

The error message ‘Your request is not valid’ and “The EstimateStartTime field is required” are predefined. How can I implement localization for these predefined error message? Do you have any suggestion?

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    You can localize "Your request is not valid" from this XML file: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web.Resources/Localization/AbpWeb/AbpWeb.xml">https://github.com/aspnetboilerplate/as ... AbpWeb.xml</a> It's located in Localization folder of your Web project.

    "The EstimateStartTime field is required" can not be localized for now. But, I strongly recommend to make validation client side. Normally, these messages must be shown only an invalid valitation is done in client or user somehow disabled client side validation.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    lcyhjx created

    Thanks, got it. yes, I have made validation on client side ,but to make sure application reliability, I make the validation on server side also. I think I can use CustomValidate to address this issue. Thanks again.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)