Change the locale of the grid validation

Hello there. I have the following requirement: enable italian localized validation messages on grid component. Following the guide here:

http://help.syncfusion.com/ug/aspnetmvc/Documents/validation.htm

I've been able to enable validation for my grid, while adding or editing a record. Now I want to localize all the validation messages in italian. I thought that I would need to set the correct grid locale, so, following the guide here:

http://help.syncfusion.com/ug/aspnetmvc/Documents/localization4.htm

I added this to my grid:

.Locale("it-IT")

and I also added the following reference in _Layout.cshtml:

<script src="@Url.Content("~/Scripts/globalize/cultures/globalize.culture.it-IT.min.js")"></script>

This correctly changed the localization (the currency unit is now € instead of $) but the validation messages are still in english. The only approach which has been successful so far was to manually edit the validation messages icluded in "jquery.validate.min.js", but I doubt that it's the best way to achieve my requirement. What's the best way to solve this issue? Thanks.


1 Reply

IR Isuriya Rajan Syncfusion Team September 1, 2015 10:04 AM UTC

Hi Carlo,


Thanks for using the Syncfusion products.


We can provide the localization support for a validation message based in any language. We have to use localization script file in the Layout page for each language.


<head>

  <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width" />

    <title>@ViewBag.Title</title>

    <link rel='nofollow' href="/Content/ej.widgets.core.min.css" rel="stylesheet" />

    <link rel='nofollow' href="/Content/ej.theme.min.css" rel="stylesheet" />

    <link rel='nofollow' href="/Content/Site.css" rel="stylesheet" />

    <script src="/Scripts/jquery-1.10.2.min.js" ></script>

    <script src="/Scripts/jquery.easing-1.3.js"></script> 

    <script src="/Scripts/jquery.globalize.min.js" ></script>

    <script src="/Scripts/jsrender.min.js" ></script>

         // Validation script file

    <script src="~/Scripts/jquery.validate.min.js"></script>

    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

    <script src="/Scripts/globalize.culture.de-DE.min.js"></script>

    <script src="/Scripts/globalize.culture.es-ES.min.js"></script>

    <script src="~/Scripts/globalize.culture.it-IT.min.js"></script 

         // Italian Locale script file

    <script src="~/Scripts/messages_it.js"></script>

    <script src="/Scripts/ej.web.all.min.js"></script>

    <script src="/Scripts/ej.unobtrusive.min.js"></script>

    </head>


We can set validation rule by using ValidationRules property for specific columns.

@(Html.EJ().Grid<object>("Grid")            

      // Locale language

       .Locale("it-IT")

        .Columns(col =>

        {     . . . . . . .. 

            // Validation rules

            col.Field("ShipCity").HeaderText("Ship City").ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Width(90).Add();

               . . . . . . . . .

        }))

Please refer to the following link for other languages localization reference,

https://github.com/jzaefferer/jquery-validation/tree/master/src/localization

Download the sample from the following location:

 http://www.syncfusion.com/downloads/support/forum/120100/ze/Grid_localization1087583201

Please try the above sample and let us know if it helps. If we misunderstood your query, please provide clear information regarding your requirements. It will help to provide a prompt solution.

Regards,

Isuriya R


Loader.
Up arrow icon