diff --git a/src/main/events/user-preferences/update-user-preferences.ts b/src/main/events/user-preferences/update-user-preferences.ts index 66d56d4a..f45af519 100644 --- a/src/main/events/user-preferences/update-user-preferences.ts +++ b/src/main/events/user-preferences/update-user-preferences.ts @@ -2,17 +2,23 @@ import { userPreferencesRepository } from "@main/repository"; import { registerEvent } from "../register-event"; import type { UserPreferences } from "@types"; +import i18next from "i18next"; const updateUserPreferences = async ( _event: Electron.IpcMainInvokeEvent, preferences: Partial -) => - userPreferencesRepository.upsert( +) => { + if (preferences.language) { + i18next.changeLanguage(preferences.language); + } + + return userPreferencesRepository.upsert( { id: 1, ...preferences, }, ["id"] ); +}; registerEvent("updateUserPreferences", updateUserPreferences); diff --git a/src/main/index.ts b/src/main/index.ts index cb20733a..7fac1c81 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -72,6 +72,10 @@ app.whenReady().then(async () => { where: { id: 1 }, }); + if (userPreferences?.language) { + i18n.changeLanguage(userPreferences.language); + } + WindowManager.createMainWindow(); WindowManager.createSystemTray(userPreferences?.language || "en"); });