Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(test/server): dayjs initialization issue
Elian Dorana5952b76d26b
diff --git a/apps/server/spec/setup.ts b/apps/server/spec/setup.tsindex c3b32e4776..2fae6e73ce 100644--- a/apps/server/spec/setup.ts+++ b/apps/server/spec/setup.ts@@ -1,6 +1,7 @@import { beforeAll } from "vitest";import i18next from "i18next";import { join } from "path";+import dayjs from "dayjs";beforeAll(async () => {// Initialize the translations manually to avoid any side effects.@@ -15,4 +16,8 @@ beforeAll(async () => {loadPath: join(__dirname, "../src/assets/translations/{{lng}}/{{ns}}.json")}});++ // Initialize dayjs+ await import("dayjs/locale/en.js");+ dayjs.locale("en");});diff --git a/apps/server/src/services/i18n.ts b/apps/server/src/services/i18n.tsindex 7630fbad4e..8e033bbf4b 100644--- a/apps/server/src/services/i18n.ts+++ b/apps/server/src/services/i18n.ts@@ -36,11 +36,11 @@ export async function initializeTranslations() {} catch (err) {console.warn(`Could not load locale ${dayjsLocale}`, err);}+ dayjs.locale(dayjsLocale);}export function ordinal(date: Dayjs) {return dayjs(date)- .locale(dayjsLocale).format("Do");}