-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Astro.currentLocale not working correctly in root 404.astro with i18n #12356
Comments
@otra-ch Please add a link to a reproducible example. |
I don't think your expectations are correct, or they are perhaps too broad. I think the expectation should be only for pages that don't exist that don't use the fallback. The reason why I say so is that because there's also a fallback system involved, if opted in. And if so, the page that doesn't exist will use the fallback, and the current locale should be the locale of the rewritten route. What do you think, @otra-ch ? |
Hey @ematipico, my use case is specifically about 404 pages without any fallback configuration. When a user visits /de/non-existent-page, I expect Astro.currentLocale to reflect the language in the URL ('de'), since that's what the user explicitly requested, even if the page doesn't exist. |
this was working for me in 4.15.12 but broke with 4.16.0 |
@ematipico My PR specifically handles 404 pages without any fallback configuration. |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using a 404.astro page at the root level (pages/404.astro), Astro.currentLocale always returns the defaultLocale even when visiting a different locale URL path.
Example:
Console log shows:
{ currentLocale: 'fr', url: '/de/fasf', params: {} }
This works correctly in some projects but not others with similar configurations.
My config:
What's the expected result?
Astro.currentLocale should return 'de' when visiting /de/* paths
Link to Minimal Reproducible Example
Participation
The text was updated successfully, but these errors were encountered: