Replies: 2 comments 2 replies
-
https://react.i18next.com/latest/ssr#passing-initial-translations-initial-language-down-to-client -> initial set language should be same as server and initial store should contain in eg. en-US case both en-US and en resources (if there are deviations in en-US from en) |
Beta Was this translation helpful? Give feedback.
-
Adding a function that changes the loading behavior just for this "edge"-case isn't the best idea as there are other options -> like you see in the razzle sample resolution of translations works already with a fallback from Preparing a current initialStore like https://github.com/i18next/react-i18next/blob/master/example/razzle-ssr/src/server.js#L65 and having the client using that (useSSR) should work out of the box. Not sure if you already had a look at https://github.com/isaachinman/next-i18next or the many samples out there? |
Beta Was this translation helpful? Give feedback.
-
I am using i18next in a Next.js app with server-side rendering. For that, I am initializing the language resources with data from the server, but allow to switch to other languages by fetching resources via
i18next-http-backend
. Let's now say I have anen
language in the initial resources, but the current locale isen-US
. The client would make an unnecessary network call as this exact locale is not in the initial resources, but the server still only provides anen
language.In a server-side rendering scenario, it would be nice to have an option to prefer the already provided (initial) resources before making a network call. So if the current locale is
en-GB
it should first checken-US
anden
in the local resources, but if not found then reload it.But maybe I miss something here, why I want to discuss it before creating a feature proposal.
Beta Was this translation helpful? Give feedback.
All reactions