From 866bb0345fe8b1aa9f60f4de6486bbc95c608107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=20Keskim=C3=A4ki?= Date: Thu, 9 Mar 2023 14:03:22 +0200 Subject: [PATCH] Only allow Finnish as language selection for now --- src/client/components/NavBar/NavBar.tsx | 3 ++- src/client/util/il18n.ts | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client/components/NavBar/NavBar.tsx b/src/client/components/NavBar/NavBar.tsx index 7ebf3a34..ba7ef628 100644 --- a/src/client/components/NavBar/NavBar.tsx +++ b/src/client/components/NavBar/NavBar.tsx @@ -20,6 +20,7 @@ import { useTranslation } from 'react-i18next' import hyLogo from '../../assets/hy_logo.svg' import styles from './styles' import useLoggedInUser from '../../hooks/useLoggedInUser' +import { inProduction } from '../../../config' const NavBar = () => { const { t, i18n } = useTranslation() @@ -35,7 +36,7 @@ const NavBar = () => { }, [user, i18n]) const { language } = i18n - const languages = ['fi', 'sv', 'en'] + const languages = inProduction ? ['fi'] : ['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 cf1d6aa8..0405c13a 100644 --- a/src/client/util/il18n.ts +++ b/src/client/util/il18n.ts @@ -4,6 +4,7 @@ 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 { @@ -11,6 +12,8 @@ declare global { } } +const defaultLanguage = inProduction ? 'fi' : 'en' + const initializeI18n = () => i18n.use(initReactI18next).init({ resources: { @@ -18,8 +21,8 @@ const initializeI18n = () => fi, sv, }, - lng: 'en', - fallbackLng: 'en', + lng: defaultLanguage, + fallbackLng: defaultLanguage, defaultNS: 'common', })