mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-15 09:11:57 +10:00
feat(client): add language selector, language detector and privacy/tos pages
This commit is contained in:
@ -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}</>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user