While using the next-i18next library in a NextJS and Typescript project, I came across an issue mentioned at the end of this post. Can anyone provide guidance on how to resolve it? I have shared the code snippets from the files where I have implemented the library below.
_app.tsx
import { appWithTranslation } from "next-i18next"
const MyApp = ({ Component, pageProps }: AppProps) => {
return <Component {...pageProps} />
}
export default appWithTranslation(MyApp);
index.tsx
export const getStaticProps = async ({ locales }:{locales: string}) => {
return {
props: { ...(await serverSideTranslations(locales, ['common'])) }
};
};
next-i18next.config.js
module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'it']
},
}
next.config.js
const { i18n } = require('./next-i18next.config');
module.exports = {
i18n
}
ERROR:
Error: Initial locale argument was not passed into serverSideTranslations
enter code here