0

I'm trying to do i18n translation using next-i18next in Next.js

My current code in _app.ts

export default appWithTranslation(MyApp);

export const getStaticProps = async () => {
  const res = await api.get('/translation');
  const name = res.data.name as string;

  return {
    props: await serverSideTranslations(name, [name], {
      i18n: {
        defaultLocale: name,
        locales: [name],
      },
      lng: name,
      fallbackLng: 'en',
      interpolation: {
        escapeValue: false,
      },
      resources: {
        [res.data.name]: {
          translation: res.data.config,
        },
      },
    }),
  };
};

I'm getting an api response with a translation json in it. The current one is not applying translations to page

Swapnil Soni
  • 965
  • 1
  • 10
  • 26

0 Answers0