remove 'This aritlce is also available ...' when changing back to Eng… (#29868)

remove 'This aritlce is also available ...' when changing back to English
This commit is contained in:
Peter Bengtsson 2022-08-11 23:21:44 +02:00 коммит произвёл GitHub
Родитель 126b0a9f44
Коммит 1897eb1c94
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -1,10 +1,12 @@
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import { useRouter } from 'next/router'
import { languageKeys } from '../../lib/languages.js' import { languageKeys } from '../../lib/languages.js'
import { PREFERRED_LOCALE_COOKIE_NAME } from '../../lib/constants.js' import { PREFERRED_LOCALE_COOKIE_NAME } from '../../lib/constants.js'
export function useUserLanguage() { export function useUserLanguage() {
const { locale } = useRouter()
const [userLanguage, setUserLanguage] = useState<string>('en') const [userLanguage, setUserLanguage] = useState<string>('en')
useEffect(() => { useEffect(() => {
@ -22,7 +24,7 @@ export function useUserLanguage() {
if (languagePreferred) { if (languagePreferred) {
setUserLanguage(languagePreferred) setUserLanguage(languagePreferred)
} }
}, []) }, [locale])
return { userLanguage } return { userLanguage }
} }