title | page_title | description | previous_url | slug | position |
---|---|---|---|---|---|
Localization |
Localization |
Learn how to use the {{ site.product }} localization files in order to change the default messages of helpers. |
/localization, /getting-started/localization |
overview_localization_core |
3 |
Localization is the process of adapting software to meet the requirements of local markets and different languages.
You can change the messages that are displayed in the {{ site.product }} helpers by including an additional script file in the document.
Officially, the {{ site.product }} components support only the English language. The community contributes to translating the messages to other languages by adding new messages
JavaScript files and updating the existing ones in the Kendo UI Core repository.
To display messages in different languages, {{ site.product }} uses localization (resource) files, for example, Messages.es-ES.resx
. The localization files are generated from the messages
JavaScript files.
You can find the resource files in the Telerik UI source zip bundle:
{% if site.core %}
-
Log in to your Telerik account.
-
Go to the Telerik UI for ASP.NET Core download page and download the
telerik.ui.for.aspnet.core.{{ site.mvcCoreVersion }}.commercial-source.zip
file. -
Extract the archive and navigate to the
\src\AspNet.Core\Kendo.Mvc\Resources\
folder that contains the resource files. {% else %} -
Log in to your Telerik account.
-
Go to the Telerik UI for ASP.NET MVC download page and download the
telerik.ui.for.aspnetmvc.{{ site.mvcCoreVersion }}.commercial-source.zip
file. -
Extract the archive and navigate to the
\src\Kendo.Mvc\Kendo.Mvc\Resources\
folder that contains the resource files. {% endif %}
Changes made to the
messages
files through community contribution will be reflected in the {{ site.product }} release that follows that contribution. Refer to the section on contributing.
{% if site.core %}
By default, all Telerik UI for ASP.NET Core helpers display their messages in US English. To replace the default text messages, include a language specific kendo.messages.<language>.js
file in the document.
Include the localization script before the helpers are initialized. The best place to include it is right after the Kendo UI JavaScript files.
The following example demonstrates how to register the localization script in the _Layout.cshtml
file.
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/kendo-ui/js/kendo.all.min.js"></script>
<script src="~/lib/kendo-ui/js/kendo.aspnetmvc.min.js"></script>
<script src="~/lib/kendo-ui/js/cultures/kendo.messages.es-ES.min.js"></script>
The following example demonstrates how to register the localization script in the_Layout.cshtml
file by using 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/kendo.aspnetmvc.min.js"></script>
<script src="https://kendo.cdn.telerik.com/<version>/js/messages/kendo.messages.es-ES.min.js"></script>
To change the current culture and language dynamically, refer to the [demo on globalization by the Grid](https://demos.telerik.com/{{ site.platform }}/grid/globalization).
Currently, translations are not available for every language and some of the localization files may be incomplete. For more information on the full list of available translations, refer to the section on contributing.
The localization script replaces the default messages in the helper prototype with their equivalent translations. The file has to be named by following the kendo.messages.<language>.js
convention. A language code identifier list is available for free download from the Microsoft developer network website.
The following example demonstrates how to create a new localization file. The kendo.messages.en-US.js
contains all messages and may be used as a reference when you create the new localization file—copy the file, rename it, and translate the messages.
/* <Helper-name> messages */
if (kendo.ui.<Helper-name>) {
kendo.ui.<Helper-name>.prototype.options.messages =
$.extend(true, kendo.ui.<Helper-name>.prototype.options.messages,{
"<message-name>": "<translation",
//...
});
}
{% else %}
The culture that is used for the localization messages in Telerik UI for ASP.NET MVC is determined by the CurrentUICulture
, not by the CurrentCulture
property. By default, if CurrentUICulture
is not supported, the Telerik UI for ASP.NET MVC helpers will display their messages in American English (en-US). If CurrentUICulture
is set from code or from the web.config
file, Telerik UI for ASP.NET MVC will use localized user interface messages.
Telerik UI for ASP.NET MVC uses satellite assemblies to support localization (user interface messages localized for a set of cultures). To change the provided localization messages, you have to build a custom Kendo.Mvc.dll
version because Kendo.Mvc.dll
is a strongly named assembly and its private key is not shipped as part of the distribution.
To update the provided localization messages in Telerik UI for ASP.NET MVC:
-
Open the
\src\Kendo.Mvc\Kendo.Mvc.csproj
Visual Studio project. The\src
directory is available only with the commercial version of Telerik UI for ASP.NET MVC. -
Locate the
Resources
directory in the solution explorer. It contains the resource files for the supported cultures. -
Open the resource file which corresponds to the target culture, for example,
Messages.es-ES.resx
. -
Edit the resource file and save it.
-
Change the solution configuration to
Release
. -
Build the project.
-
Copy
\src\Kendo.Mvc\bin\Release\Kendo.Mvc.dll
and\src\Kendo.Mvc\bin\Release\es-ES\Kendo.Mvc.resources.dll
to your ASP.NET MVC application. -
Update the
Kendo.Mvc.dll
assembly reference to the newly copied one.
Apart from building a custom version of Kendo.Mvc.dll
, you can also specify a new value for the corresponding message in the MVC HtmlHelper configuration.
The following example demonstrates how to change the default message for the Create
toolbar command of the Grid.
@(Html.Kendo().Grid<Product>()
.Toolbar(toolbar =>
{
toolbar.Create().Text("Add new product");
})
)
To add a localization file for a new language, you have to build a custom Kendo.Mvc.dll
version because Kendo.Mvc.dll
is a strongly named assembly and its private key is not shipped as part of the distribution.
To add new localization files in Telerik UI for ASP.NET MVC:
-
Open the
\src\Kendo.Mvc\Kendo.Mvc.csproj
Visual Studio project. The\src
directory is available only with the commercial version of Telerik UI for ASP.NET MVC. -
Locate the
Resources
directory in the solution explorer. It contains the resource files for the supported cultures. -
Copy
Messages.resx
and paste it. Rename the copy toMessages.culture-code.resx
, for example,Messages.es-MX.resx
. -
Open the newly created resource file.
-
Edit the resource file and save it. The
Messagex.resx
file contains the English messages. -
Change the solution configuration to
Release
. -
Build the project.
-
Copy
\src\Kendo.Mvc\bin\Release\Kendo.Mvc.dll
and\src\Kendo.Mvc\bin\Release\es-MX\Kendo.Mvc.resources.dll
to your ASP.NET MVC application. -
Update the
Kendo.Mvc.dll
assembly reference to the newly copied one. {% endif %}
Currently, translations are not available for every language and some of the localization files may be incomplete. The full list of currently available translations is available in the Kendo UI Core repository.
If you notice any missing messages in the localization files or would like to add localization files for your language, do not hesitate to:
- Fork the repository.
- Apply the respective changes.
- Submit a pull request.
- [Overview of Globalization by {{ site.product }}]({% slug overview_globalization_core %})