-
Notifications
You must be signed in to change notification settings - Fork 380
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
An official way of integrating with nextjs #1339
Comments
Related #1194 I also tried solutions proposed in this thread and setup like this: // _app.tsx
// i18n._messages[router.locale as string] = pageProps.i18n;
// i18n._locale = router.locale as string;
const locale = router.locale as string;
const [i18n] = useState(() =>
setupI18n({
messages: {
[locale]: { ...pageProps.i18n },
},
localeData: {
en: { plurals: en },
cs: { plurals: cs },
},
locale,
}),
); But this way get hydration mismatch because global i18n doesn't configured properly and on server i've got one result on client another. |
@thekip you no need to use global i18, only with const {i18n} = useLingui() global i18 only with setup |
@dmitryshelomanov The setup would be in @thekip |
@crazyyi no, i had another error. Look at this example repo https://github.com/thekip/nextjs-translation-demo/tree/update-for-latest-lingui there is other approach to setup messages in
|
@thekip
Is there any solution to remove this warning? |
Use t`` instead of Trans in Title element <Title>{t`My Awecome Page`}</Title> |
new examples added to the repo #1550 |
@Martin005 please have a look at example i've created here https://github.com/lingui/swc-plugin/tree/main/examples/nextjs-13
I was not able to make it in a clean way because issues came from different sides.
Nextjs is quite popular framework, and we should provide a seamless way to integrate LinguiJs with it.
Problems i encountered:
_app.js
, but when you do that you will get another error. Both of this i18n methods emitschange
event and trigger rendering inside Provider while another component (App) is still in render.So the only way i've found to make it work is using private properties of i18n object. That's not how it should be.
Please review the example, and let's discuss how we can make this integration simpler.
@andrii-bodnar FYI
The text was updated successfully, but these errors were encountered: