You can set the localization for Syncfusion controls like TextBoxes, DatePicker, etc. based on the browser culture by using the locale property. There is an in-built method called the ej.browserInfo () that returns the browser information as an object. Then, pass this culture information to the locale property of the components. Refer to the following code example that demonstrates the same.
$(function () { $("#datepick").ejDatePicker({ value: new Date(), // Gets the browser culture name. locale: ej.browserInfo().culture.name }); });
In the code, ej.browserInfo().culture.name is specified as the value for the locale property. Now, DatePicker control culture is set based on the browser culture. You can also set the browser culture to the controls dynamically by using their instance, as given in the following code example.
//Creates an object for the DatePicker control. obj = $("#datepick").data("ejDatePicker"); // Sets the locale to the control dynamically. obj.option("locale", ej.browserInfo().culture.name);
To apply a different culture to the components other than the English culture, include the corresponding culture file. So, based on the browser culture, include the corresponding culture file in the application. The globalize.cultures.js is a combined script file for all the cultures, and includes all the culture-related files. Sample Links:For globalize.culture.js: https://ajax.aspnetcdn.com/ajax/globalize/0.1.1/cultures/globalize.cultures.js For online documentation: https://help.syncfusion.com/js/localization |
This page will automatically be redirected to the sign-in page in 10 seconds.