next-translate
next-translate copied to clipboard
How to load all locales once
Hi guys.
I try new version with load namespace in gSP and have problem
When switching between pages, namespaces disappear. I want to load them once to avoid duplicating code in every page
@popuguytheparrot The problem you mention is a limitation that now has Next.js when loading the SSG props, however, it is already caching when you navigate to the same page and therefore in this case does not download the namespaces again.
I have created an issue https://github.com/vercel/next.js/issues/19050 with an implementation proposal in Next.js, if this is carried out I suppose that then it will be easy to solve it.
@aralroca no way to get the lang in _app gip?
@aralroca no way to get the lang in _app gip?
Sure, you can just use the next-translate/appWithI18n
in _app.js just for that, skiping the "build step". The only thing is that using a getInitialProps means that you are skiping also the page optimization. In other words, you don't have the pages prerendered at build time and you need to render them on request time, wasting CPU and time on each request
avoid duplicating code in every page
@popuguytheparrot why you need to duplicate code in order to load the namespaces? This is done automatically by the "build step", and after 1.0.0 will be done even more transparent.