-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Add reloadOnPrerender
option to reload resources in serverSideTranslations so that developers don't have to restart their server when making changes to their translation JSON files
#1359
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/isaachinman/next-i18next/BEzd7D7c8D1QEQiNm44sFeKpZPfK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat surprised that calling reloadResources
on globalI18n
works, but if so, this is quite an easy win.
We will need test coverage, though. Thanks!
This comment has been minimized.
This comment has been minimized.
@isaachinman Let me know if this test implementation seems correct. In order to test if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test coverage looks fine. Just had a passing thought about the API signature to avoid unintended regressions in prod envs.
If my understanding is correct, this will not enable HMR of locale files. If that's the case, I think we shouldn't have dismissed #1370 as it provides better DX. |
@janklimo As I've stated numerous times, This PR, however, is a one-liner and is easy to maintain. |
@isaachinman I see, thank you for your response. I'm just getting started with the package so I'm not aware of the previous conversations. Would you have any pointers to a resource which explains how it can be easily done using i18next config? Perhaps we could add a readme section explaining it? |
Hi! Is this complete functionality? Would reeeally make DX better on the app i'm working at the moment. Is it gonna be included in a release soon? |
The |
Thank you for the release! Saving the .json doesn't load the new strings after turning on the option but i suppose it's because modifying components and saving those files doesn't make |
Yes. If it's gssp, you have to reload the page |
Is there a way to live update app when changes are made to translation files in |
It only works for me if the translations are JavaScript files that are exporting the translation object and using that in i18n.resources |
@CommanderRedYT Thanks for helping out! Adding following to import en from "./locales/en/common.json" assert { type: "json" }
import fr from "./locales/fr/common.json" assert { type: "json" } |
I talked with @isaachinman at the bottom of this thread (issue #881) regarding a solution to call
i18n.reloadResources()
inside ofserverSideTranslations
. Looks like there are several issues that have been created about this topic.I've created a new config option called
reloadOnPrerender
that reloads the resources inseverSideTranslations
. I've updated the README as well.