diff --git a/src/components/LanguageSwitcher.js b/src/components/LanguageSwitcher.js index 674b500..fcc53b7 100644 --- a/src/components/LanguageSwitcher.js +++ b/src/components/LanguageSwitcher.js @@ -1,43 +1,46 @@ -import { Select } from "@chakra-ui/react"; +import { Select } from '@chakra-ui/react'; import Flags from 'country-flag-icons/react/3x2'; -import { useTranslation } from "react-i18next"; -import { useDispatch } from "react-redux"; -import { setLanguage } from "../features/auth/langSlice"; - +import { useTranslation } from 'react-i18next'; +import { useDispatch } from 'react-redux'; +import { setLanguage } from '../features/auth/langSlice'; function LanguageSwitcher() { - const [, i18n] = useTranslation(); - const dispatch = useDispatch(); - - const currentLangIcon = (() => { - switch (i18n.language) { - case "en": - return ; - case "ms": - return ; - case "zh": - return ; - case "ta": - return ; - default: - return ; - } - })(); + const [, i18n] = useTranslation(); + const dispatch = useDispatch(); - const handleSelectLanguage = (e) => { - const languageKey = e.target.value; - i18n.changeLanguage(languageKey); - dispatch(setLanguage(languageKey)); + const currentLangIcon = (() => { + switch (i18n.language) { + case 'en': + return ; + case 'ms': + return ; + case 'zh': + return ; + case 'ta': + return ; + default: + return ; } - return ( - + })(); - ); + const handleSelectLanguage = e => { + const languageKey = e.target.value; + i18n.changeLanguage(languageKey); + dispatch(setLanguage(languageKey)); + }; + return ( + + ); } -export default LanguageSwitcher; \ No newline at end of file +export default LanguageSwitcher; diff --git a/src/i18n.js b/src/i18n.js index 8e7b3c6..588bd88 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -18,12 +18,12 @@ const resources = { }, ta: { common: taTranslation, - } + }, }; i18n.use(initReactI18next).init({ resources, - lng: Cookies.get('lang') ? Cookies.get('lang') : "en", + lng: Cookies.get('lang') ? Cookies.get('lang') : 'en', defaultNS: 'common', interpolation: { escapeValue: false,