如何本地化alloyui调度程序组件?

时间:2017-08-20 10:22:36

标签: yui3 alloy-ui

我正在尝试用法语完全本地化alloyui调度程序。 在这篇文章之后:How can I get a localized version of a YUI 3 or AlloyUI component?这项工作差不多完成了。 但是我仍然缺少两件事的提示: - 我需要将左栏中的时间格式从1-12am / pm更改为1-24 - 我没有成功地将左上角的“全天”术语本地化(或至少隐藏它的方式)。

欢迎任何帮助

1 个答案:

答案 0 :(得分:0)

要更改为24小时制,您需要为正在使用的每个true子类设置isoTime attributeSchedulerView

要对字符串进行国际化,您需要设置SchedulerSchedulerDayView SchedulerWeekViewSchedulerMonthViewSchedulerAgendaViewstrings属性,以及SchedulerEventRecorder以及将YUI's lang attribute设置为您选择的区域设置。例如,我已使用Google Translate *将以下Scheduler国际化为西班牙语用户:

YUI({lang: 'es-ES'}).use('aui-scheduler', function (Y) {
    var es_ES_strings_allDay = { allDay: 'todo el dia' };
    new Y.Scheduler({
        render: true,
        // https://alloyui.com/api/classes/A.Scheduler.html#attr_strings
        // https://github.com/liferay/alloy-ui/blob/3.0.3-deprecated.65/src/aui-scheduler/js/aui-scheduler-base.js#L606-L622
        strings: {
            agenda: 'agenda',
            day: 'día',
            month: 'mes',
            today: 'hoy',
            week: 'semana',
            year: 'año'
        },
        views: [
            // https://alloyui.com/api/classes/A.SchedulerDayView.html#attr_strings
            // https://github.com/liferay/alloy-ui/blob/3.0.3-deprecated.65/src/aui-scheduler/js/aui-scheduler-view-day.js#L363-L373
            new Y.SchedulerDayView({
                isoTime: true,
                strings: es_ES_strings_allDay
            }),
            // https://alloyui.com/api/classes/A.SchedulerWeekView.html#attr_strings
            // SchedulerWeekView extends SchedulerDayView: https://github.com/liferay/alloy-ui/blob/3.0.3-deprecated.65/src/aui-scheduler/js/aui-scheduler-view-week.js#L19
            new Y.SchedulerWeekView({
                isoTime: true,
                strings: es_ES_strings_allDay
            }),
            // https://alloyui.com/api/classes/A.SchedulerMonthView.html#attr_strings
            // https://github.com/liferay/alloy-ui/blob/3.0.3-deprecated.65/src/aui-scheduler/js/aui-scheduler-view-week.js#L19
            new Y.SchedulerMonthView({
                isoTime: true,
                strings: {
                    showMore: 'mostrar {0} más',
                    close: 'cerrar'
                }
            }),
            // https://alloyui.com/api/classes/A.SchedulerAgendaView.html#attr_strings
            // https://github.com/liferay/alloy-ui/blob/3.0.3-deprecated.65/src/aui-scheduler/js/aui-scheduler-view-week.js#L19
            new Y.SchedulerAgendaView({
                isoTime: true,
                strings: {
                    noEvents: 'No hay eventos futuros'
                }
            })
        ],
        // https://alloyui.com/api/classes/A.SchedulerEventRecorder.html#attr_strings
        // https://github.com/liferay/alloy-ui/blob/3.0.3-deprecated.65/src/aui-scheduler/js/aui-scheduler-view-week.js#L19
        eventRecorder: new Y.SchedulerEventRecorder({
            strings: {
                'delete': 'borrar',
                'description-hint': 'descripción insinuación',
                cancel: 'cancelar',
                description: 'descripción',
                edit: 'editar',
                save: 'salvar',
                when: 'cuando'
            }
        })
    });
});

*我不建议使用谷歌翻译来国际化生产应用程序,因为国际化有很多细微差别,机器翻译将会遗漏。