-
-
Notifications
You must be signed in to change notification settings - Fork 761
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
Non-nullable i18n instance #2079
Comments
The problem is, the i18next instance is not always the same and the initialization is asynchronous... and serverSideTranslations makes sure the correct language and namespaces are loaded... Maybe alternatively there is the possibility to inject the onPreInitI18next option? => https://github.com/i18next/next-i18next/blob/master/src/createClient/node.ts#L37 I don't know if it makes sense to have a helper function (like your workaround) to be exposed as official api... |
Sure, the But I understand this might be quite an unusual use case. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
🚀 Feature Proposal
Add the ability to initialize the i18n instance manually. So you can easily call any method from
i18n
in thegetServerSideProps
lifecycle method.Motivation
I have a use case where I want to dynamically add resource bundles by calling
i18n.addResourceBundle
method. However, on the initial render, thei18n
instance isn't defined yet.The example below demonstrates the current limitation because i18n might be null
From your code, I can see
i18n
gets defined twice. First by appWithTranslation and createClient/node.tsExample
This is my workaround:
Another possible solution might be creating a wrapper around
next.config.js
file. Such as https://github.com/aralroca/next-translate#add-next-translate-plugin.I'm happy to hear what you think of it. Cheers
The text was updated successfully, but these errors were encountered: