fix(i18n): add missing translation keys, update lang/locale logic

This commit is contained in:
Amruth Pillai
2022-03-11 08:43:20 +01:00
parent 8bc7d2599e
commit 7d8828a358
35 changed files with 124 additions and 113 deletions
@@ -1,19 +1,17 @@
import { Language } from '@mui/icons-material';
import { IconButton, Popover } from '@mui/material';
import dayjs from 'dayjs';
import { useRouter } from 'next/router';
import { useTranslation } from 'next-i18next';
import { MouseEvent, useState } from 'react';
import { languages } from '@/config/languages';
import { setLanguage } from '@/store/build/buildSlice';
import { useAppDispatch } from '@/store/hooks';
import styles from './LanguageSwitcher.module.scss';
const LanguageSwitcher = () => {
const router = useRouter();
const dispatch = useAppDispatch();
const { t } = useTranslation();
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
@@ -24,10 +22,7 @@ const LanguageSwitcher = () => {
const handleChangeLanguage = (locale: string) => {
const { pathname, asPath, query } = router;
dayjs.locale(locale);
dispatch(setLanguage({ language: locale }));
document.cookie = `NEXT_LOCALE=${locale}; path=/; expires=2147483647`;
router.push({ pathname, query }, asPath, { locale });
};
@@ -59,7 +54,7 @@ const LanguageSwitcher = () => {
))}
<a href="https://translate.rxresu.me" target="_blank" rel="noreferrer" className={styles.language}>
Missing your language?
{t('common.footer.language.missing')}
</a>
</div>
</div>