import { useEffect, useState } from 'react'
import i18n from '../../i18n'

type Props = { language?: string }

export const useUpdateTranslations = ({ language }: Props) => {
  const [rerenderKey, setRerenderKey] = useState(0)

  useEffect(() => {
    i18n.changeLanguage(language)

    setRerenderKey((prevKey) => prevKey + 1)
  }, [language])
}
