Skip to content

Build your personal knowledge base with Trilium Notes

fix(calendar): missing locale for Russian

Elian Doran8e4691d4a44e
diff --git a/apps/client/src/widgets/view_widgets/calendar_view.spec.ts b/apps/client/src/widgets/view_widgets/calendar_view.spec.ts
index a8273239c8..ad6c38b028 100644
--- a/apps/client/src/widgets/view_widgets/calendar_view.spec.ts
+++ b/apps/client/src/widgets/view_widgets/calendar_view.spec.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import { buildNote, buildNotes } from "../../test/easy-froca.js";
-import CalendarView from "./calendar_view.js";
+import CalendarView, { getFullCalendarLocale } from "./calendar_view.js";
+import { LOCALES } from "@triliumnext/commons";
describe("Building events", () => {
it("supports start date", async () => {
@@ -174,3 +175,21 @@ describe("Promoted attributes", () => {
});
});
+
+describe("Building locales", () => {
+ it("every language has a locale defined", async () => {
+ for (const { id, contentOnly } of LOCALES) {
+ if (contentOnly) {
+ continue;
+ }
+
+ const fullCalendarLocale = await getFullCalendarLocale(id);
+
+ if (id !== "en") {
+ expect(fullCalendarLocale, `For locale ${id}`).toBeDefined();
+ } else {
+ expect(fullCalendarLocale).toBeUndefined();
+ }
+ }
+ });
+});
diff --git a/apps/client/src/widgets/view_widgets/calendar_view.ts b/apps/client/src/widgets/view_widgets/calendar_view.ts
index 65de14e4ea..4856910987 100644
--- a/apps/client/src/widgets/view_widgets/calendar_view.ts
+++ b/apps/client/src/widgets/view_widgets/calendar_view.ts
@@ -166,7 +166,7 @@ export default class CalendarView extends ViewMode<{}> {
firstDay: options.getInt("firstDayOfWeek") ?? 0,
weekends: !this.parentNote.hasAttribute("label", "calendar:hideWeekends"),
weekNumbers: this.parentNote.hasAttribute("label", "calendar:weekNumbers"),
- locale: await CalendarView.#getLocale(),
+ locale: await getFullCalendarLocale(options.get("locale")),
height: "100%",
nowIndicator: true,
handleWindowResize: false,
@@ -246,29 +246,6 @@ export default class CalendarView extends ViewMode<{}> {
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;
- }
- }
-
#onDatesSet(e: DatesSetArg) {
const currentView = e.view.type;
if (currentView === this.lastView) {
@@ -679,3 +656,26 @@ export default class CalendarView extends ViewMode<{}> {
}
}
+
+export async function getFullCalendarLocale(locale: string) {
+ // 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 "ru":
+ return (await import("@fullcalendar/core/locales/ru")).default;
+ case "en":
+ default:
+ return undefined;
+ }
+}