From 2b744c878efdcccf09ef9f950086bca85eca80b8 Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 25 Apr 2025 12:40:27 -0400 Subject: [PATCH] fix(ui): move default language initialization to Admin component Signed-off-by: Deluan --- ui/src/App.jsx | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ui/src/App.jsx b/ui/src/App.jsx index 4c6441fed..3ac705b0a 100644 --- a/ui/src/App.jsx +++ b/ui/src/App.jsx @@ -82,6 +82,25 @@ const App = () => ( ) const Admin = (props) => { + const setLocale = useSetLocale() + const refresh = useRefresh() + useEffect(() => { + if (config.defaultLanguage !== '' && !localStorage.getItem('locale')) { + retrieveTranslation(config.defaultLanguage) + .then(() => { + setLocale(config.defaultLanguage).then(() => { + localStorage.setItem('locale', config.defaultLanguage) + }) + refresh(true) + }) + .catch((e) => { + // eslint-disable-next-line no-console + console.error( + 'Cannot load language "' + config.defaultLanguage + '": ' + e, + ) + }) + } + }, [setLocale, refresh]) useChangeThemeColor() /* eslint-disable react/jsx-key */ return ( @@ -149,25 +168,6 @@ const Admin = (props) => { } const AppWithHotkeys = () => { - // Initialize default language on app mount - const setLocale = useSetLocale() - const refresh = useRefresh() - useEffect(() => { - if (config.defaultLanguage !== '' && !localStorage.getItem('locale')) { - retrieveTranslation(config.defaultLanguage) - .then(() => { - setLocale(config.defaultLanguage).then(() => { - localStorage.setItem('locale', config.defaultLanguage) - }) - refresh(true) - }) - .catch((e) => { - throw new Error( - 'Cannot load language "' + config.defaultLanguage + '": ' + e, - ) - }) - } - }, [setLocale, refresh]) let language = localStorage.getItem('locale') || 'en' document.documentElement.lang = language if (config.enableSharing && shareInfo) {