-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Changing the language the label does not update #2253
Comments
That's probably because you set the locale to 'it' here: export const getStaticProps: GetStaticProps = async () => {
const locale = "it";
return {
props: {
locale,
...(await serverSideTranslations(locale, ["common"])),
},
};
}; do this instead: export const getStaticProps: GetStaticProps<Props> = async ({
locale,
}) => ({
props: {
locale,
...(await serverSideTranslations(locale ?? 'it', [
'common'
])),
},
}) Why do you have an "en" folder? |
Thank you @adrai for your reply. Sadly this is only a replica of a bigger project that is structured this way with all italian pages on one side and all english pages under the folder |
I'm experiencing the same problem, using the 14.* version solve the issue. |
Yes @alfredosalzillo we're actually using the v14 and it works fine. While trying to upgrade to v15 I found that problem. |
Hi there, Currently experiencing the same issue while trying to upgrade from v14 to v15. My app only uses serverSideTranslations. The behaviour is the same as the codesandbox linked by @matteo-gobbo: Loading the localized homepage, switching language (through a link pointing to the localized homepage), and then the translations don't get updated until I manually refresh the page. After some debugging, I found out that if I replace the use of useLayoutEffect with a useEffect, everything works fine. It probably lets the door open to some other kind of problems (I haven't experienced any but haven't tested much either), but at least using useEffect I can switch the language and see the correct translations applied without having to refresh the page. Based on i18next docs, the changeLanguage call returns a promise. Is it really safe to call this inside a useLayoutEffect ? I think there might be a risk of the DOM getting painted while the changeLanguage call hasn't finished, which could explain why the old translations are still used. Note: I'm only experiencing this behaviour running the app through next start. If the app starts with next dev then I don't have the problem. Also, the locale isn't hardcoded in getStaticProps in my case @adrai Any thoughts? |
🐛 Bug Report
Hi, when I change la language using link at the first render the label doesn't update.
To Reproduce
A codesandbox example
To reproduce:
Expected behavior
When changing the path I expect that the label is updated too.
Your Environment
The text was updated successfully, but these errors were encountered: