Skip to content

Commit

Permalink
Finnish as default language, enable Swedish and English in production
Browse files Browse the repository at this point in the history
  • Loading branch information
Keskimaki committed May 8, 2023
1 parent 5aeb499 commit b09df7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/client/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -35,13 +35,11 @@ const NavBar = () => {
const anchorRef = useRef<HTMLButtonElement>(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)
Expand Down
7 changes: 2 additions & 5 deletions src/client/util/il18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@ 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 {
__i18n__: typeof i18n
}
}

const defaultLanguage = inProduction ? 'fi' : 'en'

const initializeI18n = () =>
i18n.use(initReactI18next).init({
resources: {
en,
fi,
sv,
},
lng: defaultLanguage,
fallbackLng: defaultLanguage,
lng: 'fi',
fallbackLng: 'fi',
defaultNS: 'common',
})

Expand Down

0 comments on commit b09df7f

Please sign in to comment.