-
Notifications
You must be signed in to change notification settings - Fork 86
Can't use i18n along with dynamic SSG #223
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
Comments
@guhur thank you SOOO much for the wonderfully detailed issue and repro. just off a very quick glance i have an inkling what could be going on, but it'll unfortunately take me a minute to get to as i'm backed up on other work. 😦 hang tight! |
@lindsaylevine thanks for your answer! Do you think you can watch over this soon? We are kind of stuck on this point since a few weeks (the rest of the development has been done). Thanks! |
@guhur just wondering, does this work on vercel as expected? |
@lindsaylevine we have the same problem with next-i18next and dynamic SSG. Any guidance when a fix (or workaround) will be available? |
friends! @iowahansen @guhur i can offer you a temporary solution right now! so, this is very similar to this longstanding issue: #153. the tl;dr of that issue is that sometimes local files needed at runtime are not bundled with their corresponding netlify function. a little while back, we added a temporary unstable solution to this plugin until our internal solution rolls out (which will be very soon!). here's what you need to do: in your next.config.js add
at the top level this ensures the public/ files are available in your runtime environment. unfortunately, when we wrote this unstable solution, we didn't write in support for individual files, like next-i18nextconfig.js, lol. but we can work around this for now. digging into the next-i18next src, you can pass your config directly to serverSideTranslations. it would look like this in your getStaticProps:
it's important to note that, unfortunately, you'll need to (for the time being) actually duplicate the config inline in your file. don't try to import it because you'll get the same error. this will be easily resolved when the internal solution rolls out. i've tested this and it works fine for me here: https://vibrant-lamarr-4157ee.netlify.app/, https://vibrant-lamarr-4157ee.netlify.app/en/test, https://vibrant-lamarr-4157ee.netlify.app/fr/test we can leave this issue open until the internal solution rolls out and clean up this workaround. let me know if this works for you!! |
actually... you might be able to do |
@lindsaylevine so cool thanks for your guidance! We are going to try it asap. |
@guhur haha yes... i was testing other strategies for a teammate and forgot i shared this link with you lmao 😅 i think the second trick (import config from '../config') should still work. just rolled back so links should work now! |
Hum I tried it and it doesn't seem to work. The deployment on Neltify returns:
Would you mind looking at it? I am feeling a bit powerless here.... The repo is here: https://github.com/MieuxVoter/mv-front-nextjs/ Thanks @lindsaylevine :) |
@guhur hey!! thanks for the repo :) change your next.config.js to:
some of the key names had typos and one needed an adjustment just because of our internal logic :) |
So cool thanks a lot for your great help @lindsaylevine! |
The quoted response said, this issue would stay open until the their is an internal solution and since this issue is close I presume their is one, but I can't seem to find any further guidance on this matter? I have implemented the suggested workaround and it works, but I would prefer a non workaround solution 👍🏻 |
Describe the bug
I am not for sure what is the bug. It is likely to be bigger than i18n.
What I observed is that next-i18next is crashing on Netlify (works on local) with dynamic SSG (works with static SSG).
To Reproduce
You can see a minimal reproducible example here:
The root page is failing with the display error:
The translated pages, such as, "https://next-i18next-netlify.netlify.app/en/test" are also failing with the error message:
(In next-i18next, you need a user config file at the root of the project to initialize i18next.)
The example is derived from next-18next example. I am assuming it is correctly done.
Expected behavior
You should see a message in English at https://next-i18next-netlify.netlify.app/en/test and in French at https://next-i18next-netlify.netlify.app/fr/test.
Versions
On my local machine (where it works): npm is at 6.14.4, nodeJs at 10.19.0 and Ubuntu at 20.04.
For the package, see: https://github.com/guhur/next-i18next-netlify/blob/master/package-lock.json
** Netlify deployement **
I created the repository from CLI. The repo has TOML configuration file.
The text was updated successfully, but these errors were encountered: