Kendo UI 全球化/语言包 [英] Kendo UI Globalization / Language packs

查看:14
本文介绍了Kendo UI 全球化/语言包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Kendo UI 不附带本地化包.您只能选择一个文化文件,它只会设置数字和日期格式,而不是小部件中显示的实际文本(例如:寻呼机文本 - 每页项目、下一页等,过滤器菜单(等于等),网格部分(在此处拖一列....)等)

Kendo UI does not come with localization packs. You can only chose a culture file which will only setup number and date formats, but not the actual texts displayed in the widgets (for example: the pager texts - items per page, next page, etc., the filter menus (Is equal to, etc.), the grid parts (Drag a column here....), etc.)

要本地化小部件,必须在每个小部件的单独选项中传递一堆消息,以覆盖 Kendo UI 默认使用的消息.像这样:

To localize a widget one must pass, in the individual options of each widget, a bunch of messages to override the messages used by default by Kendo UI. Something like this:

 filterable: {
        messages: {
            info: "Título:", // sets the text on top of the filter menu
            filter: "Filtrar", // sets the text for the "Filter" button
            clear: "Limpar", // sets the text for the "Clear" button

            // when filtering boolean numbers
            isTrue: "é verdadeiro", // sets the text for "isTrue" radio button
            isFalse: "é falso", // sets the text for "isFalse" radio button

            //changes the text of the "And" and "Or" of the filter menu
            and: "E",
            or: "Ou"
        },
        operators: {
            //filter menu for "string" type columns
            string: {
                eq: "Igual a",
                neq: "Diferente de",
                startswith: "Começa com",
                contains: "Contém",
                endswith: "Termina em"
            },
            //filter menu for "number" type columns
            number: {
                eq: "Igual a",
                neq: "Diferente de",
                gte: "Maior que ou igual a",
                gt: "Mair que",
                lte: "Menor que ou igual a",
                lt: "Menor que"
            },
            //filter menu for "date" type columns
            date: {
                eq: "Igual a",
                neq: "Diferente de",
                gte: "Maior que ou igual a",
                gt: "Mair que",
                lte: "Menor que ou igual a",
                lt: "Menor que"
            }
        }
    },
  groupable: {
    messages: {
      empty: "Arraste colunas aqui para agrupar pelas mesmas"
    }
  }

当然,您可以在单个 JavaScript 变量中共享此选项,但随后您将面临一个意想不到的问题:如果您在单个选项变量中收集了所有小部件的所有选项的消息,它将打开所有这些选项所有网格.如果您想要一个没有分组的网格,您将必须有一个单独的本地化选项变量而没有 groupable,否则,即使您不想要,该组也会显示,因为 groupable: { messages: { ....} } 将使 Kendo 将其识别为已启用.

Of course you could share this options in a single JavaScript variable, but then you will face an unexpected problem: if you have messages for ALL options of all widgets collected in a single option variable, it will TURN ON all those options for all grids. If you want a grid without grouping you will have to have a separate localized options variable without the groupable or else, even if you don't want, the group will show because the groupable: { messages: { .... } } will make Kendo recognize it as enabled.

通过仅包含一个额外的 JavaScript 来覆盖这些消息,似乎没有任何方法可以本地化控件,如 Kendo UI 论坛.

It doesn't seem to be any way to localize the controls by including just an extra JavaScript to override those messages as can be seen on Kendo UI forums.

有没有其他方法可以做到这一点?

Is there any other way to do that?

(请注意,我将回答我自己的问题,我没有患双相情感障碍!这只是让社区参与剑道全球项目的一种方式!)

(notice that I'll be answering my own question, and I do not suffer from Bipolar Disorder! It is just a way to get the involvement of the community on the kendo-global project!)

推荐答案

github 上的 kendo-global 项目通过仅包含所需的语言文件,轻松本地化所有 Kendo UI 小部件上的所有可本地化文本,如下所示:

The kendo-global project on github makes it easy to localize all localizable texts on all Kendo UI widgets by only including the desired language file like this:

<script src="http://cdn.kendostatic.com/2012.3.1114/js/kendo.all.min.js"></script>
<script src="/js/lang/kendo.pt-BR.js"></script>

它的工作原理是覆盖小部件原型上的默认选项,因此它的工作方式就好像这些小部件是用预期语言本地创建的一样.

It works by overriding the default options on the prototypes of the widgets, so it will work as if those widgets were created natively in the expected language.

由于它不会改变任何东西,也不会覆盖任何方法,如果您需要单个小部件上的特定消息(而不是10 itens"您可能想在网格的寻呼机中显示10 个产品"...)

Since it doesn't change anything, and don't override any method, you'll still be able to pass customized options with custom messages by using the standard approach if you need a specific message on a individual widget (instead of "10 itens" you may want to show "10 products" in the pager of the grid...)

该项目目前只有几个语言包.翻译非常容易,每位译员都会获得满分.所以真的非常欢迎贡献者.

The project currently has only a few language packs. Translating is very easy and full credits will be given to every and each translator. So contributors are really, really welcome.

该项目的页面可以在这里找到:https://github.com/loudenvier/kendo-global

The project's page can be found here: https://github.com/loudenvier/kendo-global

这篇关于Kendo UI 全球化/语言包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆