initialI18nStore is empty
See original GitHub issueHi @isaachinman! I’m playing with your plugin and am thinking of replacing my custom i18next integration with it – this will be so awesome!
What I’ve noticed after a switch is that initialI18nStore
does not contain any strings at the point when the client-side app is being initialized. Here’s what I see in the page source:
__NEXT_DATA__ = {
props: { initialI18nStore: { en: {} }, initialLanguage: "en", pageProps: {} },
page: "/hello",
query: {},
buildId: "development",
};
__NEXT_LOADED_PAGES__ = [];
__NEXT_REGISTER_PAGE = function(r, f) {
__NEXT_LOADED_PAGES__.push([r, f]);
};
Both client-side and server-side translations work fine, so there is no flickering between i18n keys vs values etc. However, because the namespaces are not in initialI18nStore
, redundant requests like static/locales/en/common.json
are being made from the client right after the page load. This can potentially increase time to interactive, so I’ve decided to open this issue. WDYT?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
initialI18nStore is empty · Issue #19 · i18next/next ... - GitHub
Hi @isaachinman! I'm playing with your plugin and am thinking of replacing my custom i18next integration with it – this will be so...
Read more >Next-i18next serverSideTranslations initialI18nStore missing ...
I would like to find in the initialI18nStore all the locales defined by me in the config. Why it isn't showing all of...
Read more >How to use the i18next.isInitialized function in i18next - Snyk
toJSON = () => null // do not serialize i18next instance and send to client const initialI18nStore = {} req.i18n.languages.
Read more >All side optimized Next.js translations (a next-i18next guide)
if (opt.emptyI18nStoreStore) { // let the client fetch the translations props._nextI18Next.initialI18nStore = null }
Read more >Where does initialI18nStore come from with react-i18next ...
Coding example for the question Where does initialI18nStore come from with ... React TypeError: Cannot use 'in' operator to search for 'length' in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @isaachinman and sorry for a delay with the response. The problem is in my side project, so I’ll be able to study it on an evening or during the weekend. I still rememberer about it and am very interested in digging out the cause.
The reason why I was getting an empty store in the first project was simple: I was importing
withNamespaces
directly fromreact-i18next
instead of from my local./i18n.js
😅Hope this investigation helps future users 😉 Please not that it’s
react-i18next@0.8.0
at the time of writing.