Closed matepapp closed 4 years ago
Hello @matepapp :)
There is already an example with Next.js. It doesn't feature i18next or react-i18next because I wanted to keep things simple.
But I've made a much more complete example with those 2 libs (+ Locize provider) at https://github.com/UnlyEd/next-right-now
It uses getInitialProps though, because SSG wasn't yet released at the time, but SSG support is on my roadmap :)
Yes, I've already checked next-right-now! It's an amazing template, but it was kinda "too much" for my use case. My goal is to use the NexJS provided automatic static optimization, not the static site generation (SSG), which is released about a week ago and the example with getInitialProps
in _app.tsx
unfortunately doesn't enable that.
The reason why we use _app:getInitialProps is because we universally detect the language. If you don't need SSR nor SSG then you could remove all the code in _app:getInitialProps and detect the language on the browser only. But in such case, you don't need universal-language-detector at all.
This lib is only useful if you need to detect the langage both on the server and on the browser. But I'm not sure I understand perfectly your use case.
@matepapp You should take a look at this discussion, surely you'll find a few things that helps :) https://github.com/zeit/next.js/discussions/10651#discussioncomment-537
thanks @Vadorequest, I've figured it out that we can go with client-only language detection and simple use react-i18next
. I think I can close this issue if you don't mind.
Hey @Vadorequest 👋
Thanks for creating this library! Can please provide an example how to integrate it with i18next and react-i18next? Optionally, without the usage of
getInitialProps
in custom_app
, since I wouldn't want to opt-out of automatic static optimization!Thanks in advance!