Kendo UI for jQuery Internationalization Overview
The internationalization approaches in Kendo UI for jQuery apply the desired cultures by providing services for defining the desired cultures and parsing and formatting of dates and numbers.
Getting Started
Kendo UI provides a way to internationalize the current page using a culture script. Kendo UI exposes culture (cultureName
) method which allows you to select the culture script corresponding to the <language code>-<country/region code>
. For more information on the culture
method, refer to the API reference article on this method.
All Kendo UI widgets which support date or number formatting depend also on the current culture. These widgets are the more complex ones such as the Grid, ListView, Charts, and so on.
The following Kendo UI widgets depend on the current culture:
- Calendar
- DateInput
- DatePicker
- TimePicker
- DateTimePicker
- NumericTextBox
- MaskedTextBox (globalized mask literals)
- Scheduler
- Gantt
Defining the Current Culture
The default culture which Kendo UI widgets use is "en-US"
.
- You have to set the culture before the initialization of any Kendo UI widgets which rely on it.
- If you include the generic culture file, you can omit the country or region code. For example, you can use
kendo.culture.en.min.js
withkendo.culture("en");
instead ofkendo.culture.en-GB.min.js
withkendo.culture("en-GB");
. However, the generic files do not carry country or region specifics and can only serve as a more generic representation.
To define the current culture:
-
Add the required culture script to the page, as demonstrated in the example below.
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script> <script src="kendo.all.min.js"></script> <script src="kendo.culture.en-GB.js"></script> <!-- or when using the Kendo UI CDN --> <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script> <script src="https://kendo.cdn.telerik.com/<version>/js/kendo.all.min.js"></script> <script src="https://kendo.cdn.telerik.com/<version>/js/cultures/kendo.culture.en-GB.min.js"></script>
-
Set the culture script that Kendo UI will use.
<script type="text/javascript"> //set current to the "en-GB" culture script kendo.culture("en-GB"); </script>
Formatting Date and Number Objects
Kendo UI exposes the following methods which can format the number or date objects by using a specific format string and the current specified culture.
-
kendo.toString(object, format, [culture])
—Returns a string representation of the current object while taking into account the given format and culture. -
kendo.format(format, arguments)
—Replaces each format item in a specified string with the text equivalent of a corresponding object value.
For more information, refer to the article on date formatting.
Parsing Strings
Kendo UI exposes the following methods which convert the specified string to a date or number object.
-
kendo.parseInt(string, [culture])
—Converts a string to a whole number by using the specified culture (current culture by default). -
kendo.parseFloat(string, [culture])
—Converts a string to a number with a floating point by using the specified culture (current culture by default). -
kendo.parseDate(string, [formats], [culture])
—Converts a string to a JavaScriptDate
object and takes into account the given formats or the set of default formats for the given culture.
For more information, refer to the article on date parsing.