如何本地化每页和项目的剑道网格默认文本项

时间:2013-06-24 23:39:10

标签: localization internationalization kendo-grid

在kendo网格的页脚中,它显示“每页项目数”和“项目”如何将它们放在资源文件中进行本地化。 谢谢,

3 个答案:

答案 0 :(得分:3)

在构建网格并设置其属性(如过滤,列名等)时。 您可以将自定义kendo网格消息覆盖为:

 gridbuilder.Pageable().Messages(m => {
                     m.Display("{0} - {1} of {2} My customized items");
                     m.Empty("No result found custom msg");
                     })

然后可以轻松地将显示和清空的内容,每页的项目...等属性移动到资源文件并从资源文件中读取。

答案 1 :(得分:3)

您可以按如下方式本地化或修改文本

 pageable: {
  messages: {
    display: "{0} - {1} of {2} items", //{0} is the index of the first record on the page, {1} - index of the last record on the page, {2} is the total amount of records
    empty: "No items to display",
    page: "Page",
    of: "of {0}", //{0} is total amount of pages
    itemsPerPage: "items per page",
    first: "Go to the first page",
    previous: "Go to the previous page",
    next: "Go to the next page",
    last: "Go to the last page",
    refresh: "Refresh"
   }
}

参考http://demos.telerik.com/kendo-ui/grid/localization

答案 2 :(得分:1)

如果您不想更改寻呼机消息的实际情况,那么利用Kendo culture javascript文件将是一种更好的方法。

这些文件包含本地化消息,您只需通过布局页面设置一次。

以下示例:

@using Microsoft.AspNetCore.Http;
@model Microsoft.AspNetCore.Http.HttpContext

@inject UserManager<User> UserManager
@inject IHttpContextAccessor ContextAccessor

<!-- Load kendo language and culture scripts -->
@{
    var languageDev = UserManager.GetUserAsync(ContextAccessor.HttpContext.User).Result.UserLanguageCode;
    switch (languageDev)
    {
        case "es":
        {
            <script src="~/lib/kendo-ui/js/cultures/kendo.culture.es.min.js" type="text/javascript"></script>
            <script src="~/lib/kendo-ui/js/messages/kendo.messages.es-ES.min.js" type="text/javascript"></script>
            break;
        }
        case "zh":
        {
            <script src="~/lib/kendo-ui/js/cultures/kendo.culture.zh.min.js" type="text/javascript"></script>
            <script src="~/lib/kendo-ui/js/messages/kendo.messages.zh-CN.min.js" type="text/javascript"></script>
            break;
        }
        case "ru":
        {
            <script src="~/lib/kendo-ui/js/cultures/kendo.culture.ru.min.js" type="text/javascript"></script>
            <script src="~/lib/kendo-ui/js/messages/kendo.messages.ru-RU.min.js" type="text/javascript"></script>
            break;
        }
        default:
        {
            <script src="~/lib/kendo-ui/js/cultures/kendo.culture.en.min.js" type="text/javascript"></script>
            <script src="~/lib/kendo-ui/js/messages/kendo.messages.en-GB.min.js" type="text/javascript"></script>
            break;
        }

    }

    <script type="text/javascript">kendo.culture("@languageDev");</script>
}

查看可用的文化列表:https://cdnjs.com/libraries/kendo-ui-core