Closed Vahan0799 closed 1 year ago
This sees to be the problem: https://github.com/Vahan0799/ifilm-nextjs/pull/1
This sees to be the problem: Vahan0799/ifilm-nextjs#1
Ohh that's totally my bad. THANK YOU for taking time and resolving it. And of course Thanks for such quick feedback
I fetch data from outsource API, once I switch language it updates with new language, but I also wanted to have local translations with using
useTranslation()
. To useuseTranslation()
I had to declareserverSideTranslations
ingetServerSideProps
otherwise it didn't work. So at this case it works only one feature instead of both. I can either have local translations withserverSideTranslations
or just API translations. It needs to reload the page to get correct language data fetched from API.Here's the piece of code at my
index.js
which cause the issue. export const getServerSideProps = async ({ locale }) => ({ props: { locale, ...(await serverSideTranslations(locale, ['common', 'homePage'])), } });And here's the Demo with current issue. At the home page you can change the language and see nothing happens with the titles under movie posters, but if you open any movie route which is dynamic and change the language from there, it works correctly as it should be, since I didn't use
getServerSideProps
there yet.here's the package versions that I use
"i18next": "^23.2.11", "next": "13.4.9", "next-i18next": "^14.0.0", "react-i18next": "^13.0.2",
i18n Configs in
next-i18next.config.js
file.i18n: { defaultLocale: 'en', locales: ['en', 'ru'], localePath: './public/locales', localeExtension: 'json', localeStructure: '{{lng}}/{{ns}}', /* To avoid issues when deploying to some paas (vercel...) / localePath: typeof window === 'undefined' ? require('path').resolve('./public/locales') : '/locales', },
If any other info required, here's the repo please