-
|
Using the new i18n routing, the locale is stripped from the pathname when I try to get it. In the documentation for
However that's not true with the new i18n pathname routing. If the url is "/en/something" then I've tried using Edit:I found the issue here - #18782 Is there a way to get the localized pathname or somehow to know if the user came from a localized path? For example: If the default locale is EN, there's no way to check if the user came from "/en/something" or "/something". |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
After a lot of debugging I found a good way to do a check for this: Use |
Beta Was this translation helpful? Give feedback.
-
|
thanks for this solution, @EmilTruthful - I had this problem on a big international localization project and using work around I am able to enable the default locale from all locales without it rerouting to the host country. Thanks again for posting it! |
Beta Was this translation helpful? Give feedback.
After a lot of debugging I found a good way to do a check for this:
Use
context.req.__nextStrippedLocale. It works ongetServerSidePropsandgetInitialPropsand it returnstrueif the current pathname is localized, otherwise it'sundefinedif there is no locale in the pathname.