feat(client): add language selector, language detector and privacy/tos pages

This commit is contained in:
Amruth Pillai
2022-03-08 22:57:47 +01:00
parent bf9da32465
commit a131bb3652
32 changed files with 423 additions and 2100 deletions

View File

@ -1,4 +1,26 @@
import { useRouter } from 'next/router';
import { useEffect } from 'react';
import { useAppSelector } from '@/store/hooks';
const LocaleWrapper: React.FC = ({ children }) => {
const router = useRouter();
const language = useAppSelector((state) => state.build.language);
useEffect(() => {
if (!language) return;
const { code } = language;
const { pathname, asPath, query, locale } = router;
document.cookie = `NEXT_LOCALE=${code}; path=/; expires=2147483647`;
if (locale !== code) {
router.push({ pathname, query }, asPath, { locale: code });
}
}, [router, language]);
return <>{children}</>;
};