From 53a3c92fdbece42ebe8de676330b0b77dc424490 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Fri, 28 Apr 2023 18:29:16 +0200 Subject: [PATCH] fix(i18n): use event to change luxon language setting Signed-off-by: Tilman Vatteroth --- .../components/application-loader/initializers/setupI18n.ts | 1 + .../layout/settings-dialog/global/language-picker.tsx | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/application-loader/initializers/setupI18n.ts b/frontend/src/components/application-loader/initializers/setupI18n.ts index 427c1996c..0d8892315 100644 --- a/frontend/src/components/application-loader/initializers/setupI18n.ts +++ b/frontend/src/components/application-loader/initializers/setupI18n.ts @@ -36,5 +36,6 @@ export const setUpI18n = async (): Promise => { } }) + i18n.on('languageChanged', (language) => (Settings.defaultLocale = language)) Settings.defaultLocale = i18n.language } diff --git a/frontend/src/components/layout/settings-dialog/global/language-picker.tsx b/frontend/src/components/layout/settings-dialog/global/language-picker.tsx index fae07707a..264d60295 100644 --- a/frontend/src/components/layout/settings-dialog/global/language-picker.tsx +++ b/frontend/src/components/layout/settings-dialog/global/language-picker.tsx @@ -65,9 +65,9 @@ export const LanguagePicker: React.FC = () => { const onChangeLang = useCallback( (event: React.ChangeEvent) => { - const language = event.currentTarget.value - Settings.defaultLocale = language - i18n.changeLanguage(language).catch((error: Error) => log.error('Error while switching language', error)) + i18n + .changeLanguage(event.currentTarget.value) + .catch((error: Error) => log.error('Error while switching language', error)) }, [i18n] )