Skip to content

Build your personal knowledge base with Trilium Notes

feat(view/calendar): add locale support

Elian Doranf8c358771741
diff --git a/src/public/app/widgets/view_widgets/calendar_view.ts b/src/public/app/widgets/view_widgets/calendar_view.ts
index ebb987839f..3d477b26bb 100644
--- a/src/public/app/widgets/view_widgets/calendar_view.ts
+++ b/src/public/app/widgets/view_widgets/calendar_view.ts
@@ -84,13 +84,37 @@ export default class CalendarView extends ViewMode {
day: t("calendar_view.day"),
list: t("calendar_view.list")
},
- firstDay: options.getInt("firstDayOfWeek") ?? 0
+ firstDay: options.getInt("firstDayOfWeek") ?? 0,
+ locale: await CalendarView.#getLocale()
});
calendar.render();
return this.$root;
}
+ static async #getLocale() {
+ const locale = options.get("locale");
+
+ // Here we hard-code the imports in order to ensure that they are embedded by webpack without having to load all the languages.
+ switch (locale) {
+ case "de":
+ return (await import("@fullcalendar/core/locales/de")).default;
+ case "es":
+ return (await import("@fullcalendar/core/locales/es")).default;
+ case "fr":
+ return (await import("@fullcalendar/core/locales/fr")).default;
+ case "cn":
+ return (await import("@fullcalendar/core/locales/zh-cn")).default;
+ case "tw":
+ return (await import("@fullcalendar/core/locales/zh-tw")).default;
+ case "ro":
+ return (await import("@fullcalendar/core/locales/ro")).default;
+ case "en":
+ default:
+ return undefined;
+ }
+ }
+
async #onEventMoved(e: EventChangeArg) {
const startDate = CalendarView.#formatDateToLocalISO(e.event.start);
let endDate = CalendarView.#formatDateToLocalISO(e.event.end);