From b09df7f7032e19895ca00c8ef88c1c762808d82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=20Keskim=C3=A4ki?= Date: Mon, 8 May 2023 13:56:48 +0300 Subject: [PATCH] Finnish as default language, enable Swedish and English in production --- src/client/components/NavBar/NavBar.tsx | 8 +++----- src/client/util/il18n.ts | 7 ++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/client/components/NavBar/NavBar.tsx b/src/client/components/NavBar/NavBar.tsx index da5d2a3c..2f3ebfe1 100644 --- a/src/client/components/NavBar/NavBar.tsx +++ b/src/client/components/NavBar/NavBar.tsx @@ -25,7 +25,7 @@ import { useTranslation } from 'react-i18next' import hyLogo from '../../assets/hy_logo.svg' import styles from '../../styles' import useLoggedInUser from '../../hooks/useLoggedInUser' -import { inProduction, FULL_URL } from '../../../config' +import { FULL_URL } from '../../../config' const NavBar = () => { const { t, i18n } = useTranslation() @@ -35,13 +35,11 @@ const NavBar = () => { const anchorRef = useRef(null) useEffect(() => { - if (!inProduction && user?.language) { - i18n.changeLanguage(user.language) - } + if (user?.language) i18n.changeLanguage(user.language) }, [user, i18n]) const { language } = i18n - const languages = inProduction ? ['fi', 'sv'] : ['fi', 'sv', 'en'] + const languages = ['fi', 'sv', 'en'] const handleLanguageChange = (newLanguage: string) => { i18n.changeLanguage(newLanguage) diff --git a/src/client/util/il18n.ts b/src/client/util/il18n.ts index 0405c13a..396cc90a 100644 --- a/src/client/util/il18n.ts +++ b/src/client/util/il18n.ts @@ -4,7 +4,6 @@ import { initReactI18next } from 'react-i18next' import en from '../locales/en.json' import fi from '../locales/fi.json' import sv from '../locales/sv.json' -import { inProduction } from '../../config' declare global { interface Window { @@ -12,8 +11,6 @@ declare global { } } -const defaultLanguage = inProduction ? 'fi' : 'en' - const initializeI18n = () => i18n.use(initReactI18next).init({ resources: { @@ -21,8 +18,8 @@ const initializeI18n = () => fi, sv, }, - lng: defaultLanguage, - fallbackLng: defaultLanguage, + lng: 'fi', + fallbackLng: 'fi', defaultNS: 'common', })