components.settings.LanguageSelector.js Maven / Gradle / Ivy
import {
Box, Autocomplete,
TextField } from "@mui/material"
import { useTranslation } from 'react-i18next'
import { normalizeLocale } from "contexts/utils/localization-utils";
import { enabledLocaleOptions } from "contexts/utils/locale";
import { getRegionAndLanguage } from "utils/language";
import { selectOption } from "utils/option-utils";
import { useLocale } from "hooks/locale"
import { useEffect, useState } from "react";
const LanguageSelector = () => {
const { locale, setLocale } = useLocale()
const [value, setValue] = useState(locale)
const { t } = useTranslation()
useEffect(() => { setLocale(value) },[value])
return (
{
event.preventDefault()
event.stopPropagation()
setValue(newOption.value);
}}
renderOption={(props, option) => {
const rl = getRegionAndLanguage(option.value)
return (
img': { mr: 2, flexShrink: 0 } }} {...props}>
{option.label}
)
}
}
renderInput={(params) => (
)}
/>
)
}
export default LanguageSelector