In order to configure our i18n with next-i18next we had to first run a script to generate a JSON file, which we then load and pass it as props to our Wrapper component.
The wrapper looks something like:
// This is the generated file
import localeTable from "../build/locale-table-en.json";
export const Wrapper: React.FC = ({ children }) => {
const TranslatedApp = appWithTranslation(() => <>{children}</>);
return (
<TranslatedApp
pageProps={localeTable as any}
router={{ locale: "en", route: "/" } as any}
Component={null as any}
/>
);
};
The solution works, but it was not easy to figure it out and also has the drawback that we now have to run a build step before taking the screenshots.
It'd be great if there was some kind of setUp running on node or even something like getStaticProps from NextJS.
In order to configure our i18n with
next-i18next
we had to first run a script to generate a JSON file, which we then load and pass it as props to our Wrapper component.The wrapper looks something like:
The solution works, but it was not easy to figure it out and also has the drawback that we now have to run a build step before taking the screenshots.
It'd be great if there was some kind of
setUp
running on node or even something likegetStaticProps
from NextJS.