mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
fix(calendar): missing locale for Russian
This commit is contained in:
parent
b371337ed2
commit
8e4691d4a4
@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user