diff --git a/apps/client/src/runtime.ts b/apps/client/src/runtime.ts index 9de27af18..4c82481b1 100644 --- a/apps/client/src/runtime.ts +++ b/apps/client/src/runtime.ts @@ -1,7 +1,7 @@ import $ from "jquery"; async function loadBootstrap() { - if (glob.isRtl) { + if (document.body.dir === "rtl") { await import("bootstrap/dist/css/bootstrap.rtl.min.css"); } else { await import("bootstrap/dist/css/bootstrap.min.css"); diff --git a/apps/server/src/assets/views/desktop.ejs b/apps/server/src/assets/views/desktop.ejs index 6ebe751ae..5ff145a8d 100644 --- a/apps/server/src/assets/views/desktop.ejs +++ b/apps/server/src/assets/views/desktop.ejs @@ -9,7 +9,11 @@ Trilium Notes - + \ No newline at end of file diff --git a/apps/server/src/routes/index.ts b/apps/server/src/routes/index.ts index bd753d3af..6bede94d7 100644 --- a/apps/server/src/routes/index.ts +++ b/apps/server/src/routes/index.ts @@ -14,7 +14,7 @@ import { generateToken as generateCsrfToken } from "./csrf_protection.js"; import type { Request, Response } from "express"; import type BNote from "../becca/entities/bnote.js"; -import { LOCALES } from "@triliumnext/commons"; +import { getCurrentLocale } from "../services/i18n.js"; function index(req: Request, res: Response) { const options = optionService.getOptionMap(); @@ -59,7 +59,7 @@ function index(req: Request, res: Response) { triliumVersion: packageJson.version, assetPath: assetPath, appPath: appPath, - isRtl: !!LOCALES.find(l => l.id === options.locale)?.rtl + currentLocale: getCurrentLocale() }); } diff --git a/apps/server/src/routes/login.ts b/apps/server/src/routes/login.ts index 2acb3a4d5..107fb1494 100644 --- a/apps/server/src/routes/login.ts +++ b/apps/server/src/routes/login.ts @@ -11,6 +11,7 @@ import totp from '../services/totp.js'; import recoveryCodeService from '../services/encryption/recovery_codes.js'; import openID from '../services/open_id.js'; import openIDEncryption from '../services/encryption/open_id_encryption.js'; +import { getCurrentLocale } from "../services/i18n.js"; function loginPage(req: Request, res: Response) { // Login page is triggered twice. Once here, and another time if the password is failed. @@ -24,6 +25,7 @@ function loginPage(req: Request, res: Response) { assetPath: assetPath, assetPathFragment: assetUrlFragment, appPath: appPath, + currentLocale: getCurrentLocale() }); } diff --git a/apps/server/src/services/i18n.ts b/apps/server/src/services/i18n.ts index 1199bd796..a23ff7ea2 100644 --- a/apps/server/src/services/i18n.ts +++ b/apps/server/src/services/i18n.ts @@ -76,3 +76,10 @@ export async function changeLanguage(locale: string) { await i18next.changeLanguage(locale); hidden_subtree.checkHiddenSubtree(true, { restoreNames: true }); } + +export function getCurrentLocale() { + const localeId = options.getOptionOrNull("locale") ?? "en"; + const currentLocale = LOCALES.find(l => l.id === localeId); + if (!currentLocale) return LOCALES.find(l => l.id === "en")!; + return currentLocale; +}