Skip to content

Build your personal knowledge base with Trilium Notes

fix(standalone): translations not working in prod

Elian Dorand68ada102647
diff --git a/apps/client-standalone/src/lightweight/translation_provider.ts b/apps/client-standalone/src/lightweight/translation_provider.ts
index 4e3831b6a3..6a194e12cb 100644
--- a/apps/client-standalone/src/lightweight/translation_provider.ts
+++ b/apps/client-standalone/src/lightweight/translation_provider.ts
@@ -1,9 +1,9 @@
import { LOCALE_IDS } from "@triliumnext/commons";
-import i18next from "i18next";
+import type i18next from "i18next";
import I18NextHttpBackend from "i18next-http-backend";
-export default async function translationProvider(locale: LOCALE_IDS) {
- await i18next.use(I18NextHttpBackend).init({
+export default async function translationProvider(i18nextInstance: typeof i18next, locale: LOCALE_IDS) {
+ await i18nextInstance.use(I18NextHttpBackend).init({
lng: locale,
fallbackLng: "en",
ns: "server",
diff --git a/apps/server/src/services/i18n.ts b/apps/server/src/services/i18n.ts
index a52367a18a..cba0dae96c 100644
--- a/apps/server/src/services/i18n.ts
+++ b/apps/server/src/services/i18n.ts
@@ -1,15 +1,15 @@
import { LOCALE_IDS, setDayjsLocale } from "@triliumnext/commons";
-import i18next from "i18next";
+import type i18next from "i18next";
import { join } from "path";
import { getResourceDir } from "./utils";
-export async function initializeTranslations(locale: LOCALE_IDS) {
+export async function initializeTranslations(i18nextInstance: typeof i18next, locale: LOCALE_IDS) {
const resourceDir = getResourceDir();
const Backend = (await import("i18next-fs-backend/cjs")).default;
// Initialize translations
- await i18next.use(Backend).init({
+ await i18nextInstance.use(Backend).init({
lng: locale,
fallbackLng: "en",
ns: "server",
diff --git a/packages/trilium-core/src/services/i18n.ts b/packages/trilium-core/src/services/i18n.ts
index c28c897787..88fc53c64e 100644
--- a/packages/trilium-core/src/services/i18n.ts
+++ b/packages/trilium-core/src/services/i18n.ts
@@ -4,12 +4,12 @@ import options from "./options";
import i18next from "i18next";
import hidden_subtree from "./hidden_subtree";
-export type TranslationProvider = (locale: LOCALE_IDS) => Promise<void>;
+export type TranslationProvider = (i18nextInstance: typeof i18next, locale: LOCALE_IDS) => Promise<void>;
export async function initTranslations(translationProvider: TranslationProvider) {
const locale = getCurrentLanguage();
- await translationProvider(locale);
+ await translationProvider(i18next, locale);
// Initialize dayjs locale.
await setDayjsLocale(locale);