mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-20 08:15:26 +02:00
28 lines
573 B
TypeScript
28 lines
573 B
TypeScript
import * as yup from "yup"
|
|
import {useTranslation} from "react-i18next"
|
|
import {useEffect} from "react"
|
|
import {de} from "yup-locales"
|
|
import en from "yup/lib/locale"
|
|
|
|
const YUP_LOCALE_LANGUAGE_MAP: Record<string, unknown> = {
|
|
"en-US": en,
|
|
"de-DE": de,
|
|
}
|
|
|
|
export default function I18nHandler(): null {
|
|
const {i18n} = useTranslation()
|
|
|
|
useEffect(() => {
|
|
i18n.on("languageChanged", newLanguage => {
|
|
// Update yup locale
|
|
const yupLocale = YUP_LOCALE_LANGUAGE_MAP[newLanguage]
|
|
|
|
if (yupLocale) {
|
|
yup.setLocale(yupLocale)
|
|
}
|
|
})
|
|
}, [i18n])
|
|
|
|
return null
|
|
}
|