From 067383a87d36bdb97c07523d4f8c1fdd3eec703f Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 14 Oct 2025 15:04:07 +0300 Subject: [PATCH] fix(desktop): window button alignment not corresponding OK if formatting locale is different --- apps/desktop/src/main.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts index 52ebe458b..a94709107 100644 --- a/apps/desktop/src/main.ts +++ b/apps/desktop/src/main.ts @@ -12,6 +12,7 @@ import { deferred } from "@triliumnext/server/src/services/utils.js"; import { PRODUCT_NAME } from "./app-info"; import port from "@triliumnext/server/src/services/port.js"; import { join } from "path"; +import { LOCALES } from "../../../packages/commons/src"; async function main() { const userDataPath = getUserData(); @@ -30,7 +31,7 @@ async function main() { // needed for excalidraw export https://github.com/zadam/trilium/issues/4271 app.commandLine.appendSwitch("enable-experimental-web-platform-features"); - app.commandLine.appendSwitch("lang", options.getOptionOrNull("formattingLocale") || options.getOptionOrNull("locale") || "en"); + app.commandLine.appendSwitch("lang", getElectronLocale()); // Disable smooth scroll if the option is set const smoothScrollEnabled = options.getOptionOrNull("smoothScrollEnabled"); @@ -128,4 +129,15 @@ async function onReady() { await windowService.registerGlobalShortcuts(); } +function getElectronLocale() { + const uiLocale = options.getOptionOrNull("locale"); + const formattingLocale = options.getOptionOrNull("formattingLocale"); + const correspondingLocale = LOCALES.find(l => l.id === uiLocale); + + // For RTL, we have to force the UI locale to align the window buttons properly. + if (formattingLocale && !correspondingLocale?.rtl) return formattingLocale; + + return uiLocale || "en" +} + main();