-
-
Notifications
You must be signed in to change notification settings - Fork 762
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
consistent I18nProvider and enable client side translation loading #1170
consistent I18nProvider and enable client side translation loading #1170
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/isaachinman/next-i18next/9AC9MtYdz3PN1vKFw9Wg4RchB7Gp |
Cool! Perhaps it would be preferable to get my PR merged and then build on top of that? I just haven't had the time/energy to make the needed adjustments yet due to a deadline coming up next week. Regarding initialLocale, I think the idea was that it shouldn't be needed anymore since we can just access the locale from the ServerRouter instance that is passed to |
Hey @DanPurdy and @skrivanos – I'd definitely rather get the initial PR merged first. This PR in its current state is just too large to review properly. Thanks! |
Hey both, thanks. Yes definitely agree that getting the initial PR in first is best, happy to help move that along if needs be. Would be good to get your thoughts on adding extra examples too, big bulk of the listed changes here are just a new yarn.lock and duplicated components, the failing check is for duplication in the components used as it's just a extra few pieces on top of the simple example. Thanks again |
I'm not sure we need an entire duplicated example dir. Can we not achieve the same result with normal documentation? |
We could just through documentation yeah, the readme i added to that example directory would just need to be pulled across and a bit of extra information added i guess? I suppose I figured that an example with it in place working follows on from how the next team have all their individual examples and makes it easier for someone to copy the implementation and due to the differences needed in the config file its not really something we can add to the simple example without making it drastically less simple 😄 Happy to do whatever is needed here to help out though. |
My general concern with having multiple example dirs is maintenance – I am a sole maintainer and have limited time. Thanks @DanPurdy! |
Fully understandable having been there myself. I'll remove the example dir and update the Readme instead with the example then. Thanks! |
* Memoize the i18n client and do not re-create it unless the route or locale has changed (fix i18next#1059). * Let Next's router locale take precedence over initialLocale (fix i18next#1023). * Bump the minimum version of react-i18next.
Bumps [i18next](https://github.com/i18next/i18next) from 19.9.2 to 20.1.0. - [Release notes](https://github.com/i18next/i18next/releases) - [Changelog](https://github.com/i18next/i18next/blob/master/CHANGELOG.md) - [Commits](i18next/i18next@v19.9.2...v20.1.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* fix: update react-i18next to resolve CVE-2021-23346 * Update examples/simple/yarn.lock Co-authored-by: Isaac Hinman <isaac@isaachinman.com>
Adds client side page example where translations are loaded via http-backend and then cached locally via localstorage
638a2bf
to
f669bf5
Compare
Hi, excuse my drop-in here, just wondering if this will be merged soon, as it would mean a lot in our project? :) Thanks for great work @isaachinman @DanPurdy @skrivanos |
Hey, once #1064 is merged in then i'll be updating this branch as this has a lot of the changes already made there too. |
@DanPurdy @isaachinman @skrivanos Hello, thanks for great work! According to this commnet #1049 (comment)
and in _app.js we will pass config to sec parameter
and in page component
Although I encounter many issues about this strategy
I want to understand the logic behind first.
thanks for your time and attention, I really want to understand these concept and confirm if I understand correctly or not Thanks a million!! |
@aNyMoRe0505 This PR isn't really the place to discuss this, best to open a discussion if you want to continue this but basically you shouldn't do both server side and client side loading yes. You kind of hit the nail on the head with point 4, you wouldn't use this client side loading strategy for SEO pages in those cases static render is the way to go if possible, server side is probably your next bet and client side being your last option (this is by no means a universal rule though!). The purpose of this PR is just to give you the option, for pages like account pages or in my use case some sort of private booking flow that will never be crawled by google and can't be statically or server rendered. In these cases you can use the |
Hi @DanPurdy, thanks for creating this PR. I am looking forward to getting this feature, after reading lots of comments about people wanting this feature back (example), issues (e.g. this one), and proposed solutions (this one or this one for instance) in this repo. I've one question though that is in the back of my head when seeing what you've created here. Especially after reading the "Client side loading of translations via HTTP" Readme. Do I need to be concerned about the maintainability of this solution, as it depends on using Thanks for your time and help. I appreciate it a lot. |
any chance this is going to be merged and published in the near future? App remounts mentioned in #1075 is a real blocker I think. |
Ping! This is an important PR, please merge |
Merging is predicated on someone rebasing this PR against latest changes, and owning any further work necessary. |
Hey all, no worries I'll be back to rebase and take a look soon, just a busy week! |
Hey @DanPurdy, I am sorry to bother you, do you think you'll take a look at this any time soon again? Thanks for your work in advance. |
Any Updates here? |
Same here, I have the _app remount issue and I'm waiting for this to be merged, any chance this is going to be merged any time soon? thanks |
I have same issse, Looking forward to the PR merged. |
#1075 has caused us quite a bit of headaches, firstly with next-auth sessions and secondly framer-motion causing animations not to render. Looking forward to the PR being merged aswell. |
Anyone able to step up and help get this PR across the line? |
@isaachinman I tried: #1726 |
We've now merged #1726. |
This follows on and includes the great work of @skrivanos in #1064 I've rebased from his PR and then applied the current master changes too (conflicts galore - happy to tidy this up)
notes from that PR
Memoize the i18n client and do not re-create it unless the route or
locale has changed (fix Re-renders of memoized components on shallow route changes #1059).
Let Next's router locale take precedence over initialLocale (fix Shallow routing does not work #1023).
Bump the minimum version of react-i18next.
Will happily rebase again if that PR is merged as it provides a great way forward but its been untouched for a few weeks
On top of that i've hopefully addressed #1049 and #1075 and also provided a path for those that want to easily load their translations client side using http-backend (not included as a dep here but with an example to show how, going to investigate the repercussions this has for fallback pages too but should provide a path forward there also).
While serverSideTranslations should still be the default for this plugin i and from the issues list a few others are looking for ways to make it easier to load translations client side to avoid the sometimes jarring user experience for an SPA of having to load routes using getServerSideProps.
Added a few more errors and fallbacks to config values plus tests around those.
I guess this PR is by no means complete but looking for your feedback around anything you're not happy with before i go much further
TODO
documentation in readme on the changes and how to use client sideMore examples for fallback routesAs per the discussion in #1064 where you were talking about removing the initialLocale prop from serverSideTranslations, I believe this should remain unless we can find a good way to ensure the language is correct on first render as your serverSideTranslations are called there before appWithTranslation has had time to create a global i18n instance. Open to thoughts and ideas here about what you had in mind if you want this prop removed.
fix #1049
fix #1075
Closed by #1726.