feat(lang): add language switcher on the landing page, in the footer

This commit is contained in:
Amruth Pillai
2022-03-10 21:59:16 +01:00
parent 036adbfc96
commit 8bc7d2599e
8 changed files with 106 additions and 13 deletions

View File

@ -63,13 +63,13 @@ const Settings = () => {
const handleChangeLanguage = (value: Language | null) => {
const { pathname, asPath, query } = router;
const locale = value?.code || 'en';
const code = value?.code || 'en';
dayjs.locale(locale);
dispatch(setLanguage({ language: locale || 'en' }));
document.cookie = `NEXT_LOCALE=${locale}; path=/; expires=2147483647`;
dayjs.locale(code);
dispatch(setLanguage({ language: code }));
document.cookie = `NEXT_LOCALE=${code}; path=/; expires=2147483647`;
router.push({ pathname, query }, asPath, { locale });
router.push({ pathname, query }, asPath, { locale: code });
};
const handleLoadSampleData = async () => {