This is a migrated thread and some comments may be shown as answers.

@Html.Kendo().Culture() doesn't seem to work properly

3 Answers 568 Views
Globalization
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 03 Aug 2016, 10:46 PM

I'm using kendo Telerik.UI.for.AspNet.Mvc5 version 2016.2.607 in .net 452

i have my culture type in web.config set as:

<globalization uiCulture="de" culture="de-DE" />

if i use the following code to localize my website, it works fine (see 'first.png')

<script src="@Url.Content("~/Scripts/kendo/2016.2.607/cultures/kendo.culture." + System.Globalization.CultureInfo.CurrentCulture.Name + ".min.js")"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                kendo.culture("@System.Globalization.CultureInfo.CurrentCulture.Name");
            });
        </script>

if i remove that code and use @Html.Kendo().Culture() instead, i en-US date values (see 'second.png')

if i do a view source, the @Html.Kendo().Culture() seems to be working fine, see below.

<script>kendo.cultures["de-DE"]={name:"de-DE",numberFormat:{pattern:["-n"],decimals:2,",":".",".":",",groupSize:[3],percent:{pattern:["-n %","n %"],decimals:2,",":".",".":",",groupSize:[3],symbol:"%"},currency:{pattern:["-n $","n $"],decimals:2,",":".",".":",",groupSize:[3],symbol:"€"}},calendars:{standard:{days:{names:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],namesAbbr:["So","Mo","Di","Mi","Do","Fr","Sa"],namesShort:["So","Mo","Di","Mi","Do","Fr","Sa"]},months:{names:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],namesAbbr:["Jan","Feb","Mrz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"]},AM:[""],PM:[""],patterns:{d:"dd.MM.yyyy",D:"dddd, d. MMMM yyyy",F:"dddd, d. MMMM yyyy HH:mm:ss",g:"dd.MM.yyyy HH:mm",G:"dd.MM.yyyy HH:mm:ss",m:"d. MMMM",M:"d. MMMM",s:"yyyy'-'MM'-'dd'T'HH':'mm':'ss",t:"HH:mm",T:"HH:mm:ss",u:"yyyy'-'MM'-'dd HH':'mm':'ss'Z'",y:"MMMM yyyy",Y:"MMMM yyyy"},"/":".",":":":",firstDay:1}}};</script>

what am i missing?

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 08 Aug 2016, 07:31 AM
Hello Brad,

Have you included the code to set the current culture?
<script type="text/javascript">
    $(document).ready(function () {
        kendo.culture("@System.Globalization.CultureInfo.CurrentCulture.Name");
    });
</script>
The Kendo.Culture() helper will only output the culture script. It will not set the culture as current.

Regards,
Daniel
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Brad
Top achievements
Rank 1
answered on 08 Aug 2016, 02:28 PM

Ah, i didn't get that at all from http://docs.telerik.com/kendo-ui/aspnet-mvc/globalization .  Thanks, it works correctly now.  What about validators?  I shouldn't need to do scripts like:

$.validator.addMethod('date',<br>               function (value, element) {<br>                   return this.optional(element) || kendo.parseDate(value)<br>               });

anymore, right?  Plus, i also shouldn't need to set the culture of kendo objects either, like:

@Html.Kendo().DateTimePickerFor(m => m.ProjectEndDate).Culture(System.Globalization.CultureInfo.CurrentCulture.Name)

?  I should be able to leave the 'culture' section out of the datetimepicker?  Or is that not how it works?

0
Accepted
Daniel
Telerik team
answered on 09 Aug 2016, 08:21 AM
Hello again,

You will still need the code for the jQuery validation. The current kendo culture is used by default only by the kendo validator. I am not sure if I understand why was setting the culture specifically to the DateTimePicker helper needed. It uses the formats from the current .NET culture by default.

Regards,
Daniel
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Globalization
Asked by
Brad
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Brad
Top achievements
Rank 1
Share this question
or