I have a dynamic page in Next JS and I wanna use i18n library for localization but when I enter the dynamic page language change to default ‘En’ .I am using getStaticProps and getStaticPaths in this page as you can see in the below. when I use useRouter and give locale the locale is correct but at the getStaticProps and getStaticPaths it has changed.
`export const getStaticProps = async (context: any) => {
const {locale, params} = context;
rest code.... here...
const newData = {
...prj,
image: imageSrc,
};
return {
props: {
...(await serverSideTranslations(locale)),
data: newData,
},
};
};`
and this getStaticPaths
`` export const getStaticPaths = async (context: any) => {
const {locales} = context;
const {data} = await getPosts();
const dataIds = data.map((item: any) => item.id);
const paths = dataIds.flatMap((item: any) => {
return locales.map((locale: any) => {
return {
params: {
id: String(item),
},
locale: locale,
};
});
});
return {
paths,
fallback: 'blocking',
};
};``
please help me to solve this issue.
tanks
I have read previous issue in stack and other articles and have done most of them but I can’t solve the issue“your text`
Ashv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.