Globalization/Localization on validated fields doesn't seem to work

4 posts, 0 answers
  1. David
    David avatar
    15 posts
    Member since:
    Mar 2019

    Posted 15 Aug 2019 Link to this post

    Hello,

    I am experiencing a problem applying culture to the validation messages in my editable grid. I experience the exact same problem as in the following demo:  https://demos.telerik.com/aspnet-core/grid/globalization?culture=fr-FR

     

    As a user I would expect the validation message to be localized but they don't seem to be.

    To reproduce,

    1. Set the culture to anything other then english,
    2. Edit a row,
    3. Empty the "Name" column,
    4. click out of the textbox to activate validation and notice that the validation message displayed is in english.

     

    Any help on this will be greatly appreciated!

    Thank you

  2. Tsvetomir
    Admin
    Tsvetomir avatar
    754 posts

    Posted 20 Aug 2019 Link to this post

    Hi David,

    Thank you for the provided information and steps on how to replicate the behavior of interest.

    The behavior that you have shared is actually a simple validation message which comes from the ASP.NET MVC Framework. And more specifically, it comes from the model. Those validation messages could be customized as follows:

    [Required(ErrorMessage = "Age is required!!")]
    public int Age { get; set; }

    The localization of the Kendo UI widgets aims to localize all of the buttons, tooltips, strings within the context of the widget. Since the validation is applied externally, it has to be handled separately.

    I hope this helps.


    Best regards,
    Tsvetomir
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. David
    David avatar
    15 posts
    Member since:
    Mar 2019

    Posted 09 Sep 2019 in reply to Tsvetomir Link to this post

    Hello Tsvetomir,

    I understand what you are saying but this is not the approach I took to fix this problem. It could of worked but our system is Database first so the model often gets refreshed & overriden by the scaffolding tools. Instead, I modified the default message templates to new localized ones. 

    To achieve this I followed the steps found here : https://blogs.msdn.microsoft.com/mvpawardprogram/2017/05/09/aspnetcore-mvc-error-message/ and customized the implementation a little bit to suit my needs.

     

    I believe your response helped me find this alternative so I am thankful :)

    Have a nice day!

    David

  4. Tsvetomir
    Admin
    Tsvetomir avatar
    754 posts

    Posted 09 Sep 2019 Link to this post

    Hi David,

    I am glad to hear that you have managed to resolve the issue. And thank you for sharing your solution with the community.

    Apart from the model's error message customization, they could be modified on the client-side. An example of a custom validation and a custom message could be found here:

    https://demos.telerik.com/aspnet-core/grid/editing-custom-validation

    However, this would change the message only on the client-side, and only for the client-side validation. If you would like it to come from the server-side, the approach suggested in the article has to be followed. 


    Kind regards,
    Tsvetomir
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top