跳转到主要内容

本地化

该库通过提供若干预定义的区域设置以及创建自定义区域设置的方法,来支持调度器的本地化。默认情况下,DHTMLX Scheduler 使用 English locale

激活

要为调度程序设置所需语言,请通过 scheduler.i18n 对象的 setLocale() 方法激活相应的区域设置。

scheduler.i18n.setLocale("fr");

您可以使用并更新捆绑在 dhtmlxscheduler.js 文件中的任意 预定义区域设置,也可以定义自定义区域设置。

注释

区域设置可以动态切换,但只有在通过 scheduler.render()scheduler.init() 调用完成重绘后,变更才会生效。

scheduler.i18n.setLocale("fr");
scheduler.init("scheduler_here");

相关示例

已包含的区域设置

注释

Common 区域设置文件和 Recurring 区域设置文件都位于 dhtmlxscheduler.js 文件中。

dhtmlxScheduler 包含以下语言的本地化:

语言语言代码
阿拉伯语ar
白俄罗斯语be
加泰罗尼亚语ca
中文cn
捷克语cs
丹麦语da
荷兰语nl
英语en (default)
芬兰语fi
法语fr
德语de
希腊语el
希伯来语he
匈牙利语hu
印尼语id
意大利语it
日语jp
挪威语no
挪威 Bokmålnb
波兰语pl
葡萄牙语pt
罗马尼亚语ro
俄语ru
斯洛伐克语sk
斯洛文尼亚语si
西班牙语es
瑞典语sv
土耳其语tr
乌克兰语ua

创建自定义区域设置

注释

在 v6.0 中新增了 scheduler.i18n 对象。在早期版本中,使用的是 scheduler.locale 对象。欲了解更多信息,请参阅 迁移文章

创建自定义区域设置的最简单方法,是从下面的示例中复制默认的英语区域设置,并将所有字符串翻译成所需语言。

自定义区域设置可以通过两种方式应用到 Scheduler:

  • 要么通过将区域设置对象作为参数传递给 setLocale() 方法来覆盖当前区域设置:
scheduler.i18n.setLocale(localeObject);

注意,如果你提供了部分区域设置对象,调度程序会将你的标签添加到当前区域设置中:

scheduler.i18n.setLocale({
labels: {
day_tab: "Day",
}
});
  • 要么,如果你需要在多个区域设置之间切换,请使用自定义语言代码定义区域设置,然后稍后将调度程序切换到它:
scheduler.i18n.addLocale("lang", localeObject);
scheduler.i18n.setLocale("lang");
注释

注意,在应用中激活自定义区域设置会导致应用界面发生变化。请检查并(如有需要)重新定义所有依赖于区域设置的元素,以确保调度程序在新语言下看起来正常。

  • 你可以将自定义区域设置文件发送至 support@dhtmlx.com,以便我们在下一个版本中加入。
  • 当前活动的区域设置也在 scheduler.locale 对象中可用。
  • monthFull - 从一月起的月份全称
  • monthShort - 从一月起的月份简称
  • dayFull - 从星期日起的周日全称
  • dayShort - 从星期日起的周日简称

English locale 定义

scheduler.i18n.setLocale({
date: {
month_full: ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"],
month_short: ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
day_full: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"],
day_short: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
},
labels: {
dhx_cal_today_button: "Today",
day_tab: "Day",
week_tab: "Week",
month_tab: "Month",
new_event: "New event",
icon_save: "Save",
icon_cancel: "Cancel",
icon_details: "Details",
icon_edit: "Edit",
icon_delete: "Delete",
confirm_closing: "", // Your changes will be lost, are your sure?
confirm_deleting: "Event will be deleted permanently, are you sure?",
section_description: "Description",
section_time: "Time period",
full_day: "Full day",

/* recurring events */
confirm_recurring: "Edit recurring event",
section_recurring: "Repeat event",
button_recurring: "Disabled",
button_recurring_open: "Enabled",
button_edit_series: "All events",
button_edit_occurrence: "This event",
button_edit_occurrence_and_following: "This and following events",

/* agenda view extension */
agenda_tab: "Agenda",
date: "Date",
description: "Description",

/* year view extension */
year_tab: "Year",

/* week agenda extension */
week_agenda_tab: "Agenda",

/* grid view extension */
grid_tab: "Grid",

/* touch tooltip */
drag_to_create: "Drag to create",
drag_to_move: "Drag to move",

/* dhtmlx message default buttons */
message_ok: "OK",
message_cancel: "Cancel",

/* wai aria labels for non-text controls */
next: "Next",
prev: "Previous",
year: "Year",
month: "Month",
day: "Day",
hour: "Hour",
minute: "Minute",

/* legacy recurring event components */
repeat_radio_day: "Daily", // name="repeat" value="day"
repeat_radio_week: "Weekly", // name="repeat" value="week
repeat_radio_month: "Monthly",
repeat_radio_year: "Yearly",
repeat_radio_day_type: "Every",
repeat_text_day_count: "day",
repeat_radio_day_type2: "Every workday",
repeat_week: " Repeat every",
repeat_text_week_count: "week next days:",
repeat_radio_month_type: "Repeat",
repeat_radio_month_start: "On",
repeat_text_month_day: "day every",
repeat_text_month_count: "month",
repeat_text_month_count2_before: "every",
repeat_text_month_count2_after: "month",
repeat_year_label: "On",
select_year_day2: "of",
repeat_text_year_day: "day",
select_year_month: "month",
repeat_radio_end: "No end date",
repeat_text_occurrences_count: "occurrences",
repeat_radio_end2: "After",
repeat_radio_end3: "End by",

/* recurring event components */
repeat_never: "Never",
repeat_daily: "Every day",
repeat_workdays: "Every weekday",
repeat_weekly: "Every week",
repeat_monthly: "Every month",
repeat_yearly: "Every year",
repeat_custom: "Custom",
repeat_freq_day: "Day",
repeat_freq_week: "Week",
repeat_freq_month: "Month",
repeat_freq_year: "Year",
repeat_on_date: "On date",
repeat_ends: "Ends",
month_for_recurring: ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"],
day_for_recurring: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"]
}
});

相关示例

其他说明

  • 如果未定义 confirm_closingconfirm_deleting 标签,相应的确认对话框将完全不显示(自动确认)
  • section_(name) 标签指的是相关名称的轻盒(lightbox)部分
  • new_event 标签定义新事件的默认文本
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.