Skip to content

TagSpaces is an offline, open source, document manager with tagging support

set i18n chosen language fixing #2030

Stanimir9b131e2baa3f
diff --git a/src/renderer/containers/Root.tsx b/src/renderer/containers/Root.tsx
index f5e1f2e30..98d4e13c9 100644
--- a/src/renderer/containers/Root.tsx
+++ b/src/renderer/containers/Root.tsx
@@ -25,7 +25,7 @@ import { actions as AppActions } from '../reducers/app';
import App from '-/containers/App';
import MainPage from '-/containers/MainPage';
import TsAuth from '-/containers/TsAuth';
-import init from '-/services/i18nInit';
+import i18nInit from '-/services/i18nInit';
import { FsActionsContextProvider } from '-/hooks/FsActionsContextProvider';
import { OpenedEntryContextProvider } from '-/hooks/OpenedEntryContextProvider';
import { DirectoryContentContextProvider } from '-/hooks/DirectoryContentContextProvider';
@@ -48,7 +48,9 @@ export default function Root({ store, persistor }: RootType) {
const [initialized, setInitialized] = useState(false);
useEffect(() => {
- init().then(() => setInitialized(true));
+ // @ts-ignore
+ const language: string = store.getState().settings.interfaceLanguage;
+ i18nInit(language).then(() => setInitialized(true));
}, []);
if (!initialized) {
diff --git a/src/renderer/services/i18nInit.ts b/src/renderer/services/i18nInit.ts
index c6eff70a2..d5ae2637f 100644
--- a/src/renderer/services/i18nInit.ts
+++ b/src/renderer/services/i18nInit.ts
@@ -22,12 +22,12 @@ import HttpBackend, { HttpBackendOptions } from 'i18next-http-backend';
import { initReactI18next } from 'react-i18next';
//import LanguageDetector from 'i18next-browser-languagedetector';
-const initI18n = async () => {
+const initI18n = async (lng = undefined) => {
await i18n
//.use(LanguageDetector)
.use(initReactI18next)
.use(HttpBackend)
- .init<HttpBackendOptions>(i18nOptions);
+ .init<HttpBackendOptions>({ ...i18nOptions, ...(lng && { lng: lng }) });
return i18n;
};