From f003e54cb9fad3bd0279fe41cbb2affd736ddc71 Mon Sep 17 00:00:00 2001 From: Levminer <33373714+Levminer@users.noreply.github.com> Date: Thu, 3 Mar 2022 22:03:03 +0100 Subject: [PATCH] Fix detecting system language #189 --- main.js | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/main.js b/main.js index ed46ea4d..ee961020 100644 --- a/main.js +++ b/main.js @@ -55,6 +55,7 @@ let manual_update = false let password_buffer = null let tray = null let menu = null +let lang = null /** * Check if running in development mode @@ -282,30 +283,6 @@ if (settings.settings.hardware_acceleration === false) { app.disableHardwareAcceleration() } -/* Set language */ -let lang = en -let locale = "en" - -if (settings.settings.language !== null) { - locale = settings.settings.language -} else { - locale = app.getLocale().slice(0, 2) -} - -switch (locale) { - case "en": - lang = en - break - - case "hu": - lang = hu - break - - default: - lang = en - break -} - /** * Show application window from tray */ @@ -403,6 +380,30 @@ const exitFromTray = () => { const createWindows = () => { logger.log("Started creating windows") + /* Set language */ + lang = en + let locale = "en" + + if (settings.settings.language !== null) { + locale = settings.settings.language + } else { + locale = app.getLocale().slice(0, 2).toLowerCase() + } + + switch (locale) { + case "en": + lang = en + break + + case "hu": + lang = hu + break + + default: + lang = en + break + } + /** * Window Controls Overlay */