In next.js i18n redirect only works from main page "/"
If cookie NEXT_LOCALE is set to "fr" it will redirect from "/" to "/fr" but it won't redirect from "/about" to "/fr/about"
const router = useRouter();
const { pathname, asPath, query } = router;
const handleSelectLanugage = (code) => {
document.cookie = `NEXT_LOCALE=${code};path=/`;
router.push({ pathname, query }, asPath, { locale: code });
};
next.config.js
i18n: {
locales: ["en", "pl", "fr"],
defaultLocale: "en",
},
What should i do to make it work for every page?