You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've set up our app with multiple languages, and every attempt to navigate to another page even with the browser back button will reset the locale back to the configured defaultLocale. It has nothing to do with useRouter or next/link, because surely the back button is supposed to work correctly.
I can see that context.locale is reset as soon as getServersideProps is executed. I don't know what could possibly sit before that, throwing a wrench in the works. We don't have any middleware meddling with locales.
We're using next-localization for translation purposes, in case that helps to know.
So what could possible be causing this? I've put console.logs all over the application, and I promise getServersideProps is always the first thing that gets executed on navigation, and that's always the point where suddently the language is reset to default.
Is there anything that happens beforegetServersideProps where I could dive in to diagnose?
What are any circumstances under which this can happen? In the documentation I can only find how it should work, but not why it wouldn't.
Can someone please point me to the source where the context object is generated? Maybe that'll help understanding where it's pulling the (incorrect) locale from.
I've looked on Stackoverflow and google halfway around the world. No one seems to have had this issue before. And as such chatGPT also goes in circles and essentially doesn't know.
PS: I'm sorry I don't have time right now to put up a reproduction case, and safe to say the application is rather more complex than a simple case atm, so this will take some time. I'm not sure yet if this is worth my time. Tomorrow I'll consult one of my coworkers as well. I'll post back results just in case anyone's interested.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
I've set up our app with multiple languages, and every attempt to navigate to another page even with the browser back button will reset the locale back to the configured defaultLocale. It has nothing to do with
useRouter
ornext/link
, because surely the back button is supposed to work correctly.I can see that
context.locale
is reset as soon asgetServersideProps
is executed. I don't know what could possibly sit before that, throwing a wrench in the works. We don't have any middleware meddling with locales.We're using
next-localization
for translation purposes, in case that helps to know.So what could possible be causing this? I've put console.logs all over the application, and I promise
getServersideProps
is always the first thing that gets executed on navigation, and that's always the point where suddently the language is reset to default.getServersideProps
where I could dive in to diagnose?context
object is generated? Maybe that'll help understanding where it's pulling the (incorrect) locale from.I've looked on Stackoverflow and google halfway around the world. No one seems to have had this issue before. And as such chatGPT also goes in circles and essentially doesn't know.
PS: I'm sorry I don't have time right now to put up a reproduction case, and safe to say the application is rather more complex than a simple case atm, so this will take some time. I'm not sure yet if this is worth my time. Tomorrow I'll consult one of my coworkers as well. I'll post back results just in case anyone's interested.
Additional information
Beta Was this translation helpful? Give feedback.
All reactions