-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translations aren't loaded while isFallback = true #575
Comments
I don't know how the isFallback works underneath, so I'll have to investigate. Thank you for reporting it @alex-ragin |
Happens to me aswell, when using fallback Vercel doesn't let me deploy as the translations outside the page arent loaded |
translations are loaded in getStaticProps. I suppose that if you have the fallback, the pages that use the fallback do not load anything (translations or whatever you put inside the getStaticProps), is that so? Or would it has to load it in runtime instead of buildtime? I haven't used the fallback feature yet so I'm not sure how it works. Thanks! |
We've noticed this problem too and have used the workaround of returning I've created a minimal reproduction of this issue here: https://github.com/ztanner/next-translate-fallback-bug, with a description in the README. Hope it helps track down the cause - I'll see if I can help investigate as well. |
I just encountered the same issue after upgrading from 1.0.5 to 1.0.7-canary.1. |
Digging through the commits since 1.0.5, I was able to pin-point the issue down to https://github.com/vinissimus/next-translate/blob/8abc45855cdc95bed873657379499c758483829a/src/useTranslation.tsx#L11
@aralroca Can you change it and release a hotfix patch version or should I create a PR? |
@berndartmueller |
Yes, I changed the code locally and verified that this causes the issue with Why is Edit: What if the relevant code uses object destructing? Like following:
Edit:
Maybe that's why there is currently a bug with |
I was too hasty with my assumption. It seems this issue exists also before version 1.0.5. Something is broken when Next.js generates this fallback page (during the initial build). Inspecting the page HTML source of a Next.js page with fallback clearly shows the missing translations. Pages that do not have a fallback (statically generated while building) do have proper translations. The reason why it "seems" to work until version 1.0.6 is simply that client-side rendering replaces the statically generated fallback page with missing translations with a re-rendered page with translations. The fix I proposed earlier (adapting |
I think I found the underlying issue: See https://nextjs.org/docs/basic-features/data-fetching#fallback-pages
Even though next-translate loads the needed translations within the webpack loader and puts it into the Next.js My idea to circumvent this would be checking if @aralroca What do you think of this? |
I am not sure is it caused by the same reason but when i return export async function getServerSideProps(context) {
const res = await fetch(`https://...`)
const data = await res.json()
if (!data) {
return {
notFound: true,
}
}
return {
props: {}, // will be passed to the page component as props
}
} |
Translations for 404 page should be added on |
But for my page, the required translation is just under |
Hey!
I noticed an issue that translations aren't loaded while in the isFallback state.
This is my
getStaticPaths
for one of the pages:getStaticProps
:So when the new props are being fetched (isFallback is true), the translations aren't loaded. Once isFallback is false, then you can see all the translations.
For now, I'm just setting if (isFallback) return null - so that the screen is white while in fallback, but this is not that user friendly :(
Do you guys have any ideas on how to fix that?
The text was updated successfully, but these errors were encountered: