-
-
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
feat(i18n): add Astro.currentLocale
#9101
Conversation
🦋 Changeset detectedLatest commit: c56b5d9 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM! Excited to see this API added!
@@ -0,0 +1,5 @@ | |||
--- | |||
'astro': patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also checking that this is a patch, so only waiting for the feature to merge but not for the next minor release? If so, please help me remember when the corresponding docs PR should merge, since it's not on the normal release schedule! 😄 withastro/docs#5410
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the PR is merged, this new thing will go out in the next release (regardless of its entity).
remember when the corresponding docs PR should merge
Ideally, we should merge it before the next release. Although we don't have a schedule for that, I think it's also okay if the docs PR is released 1/2 day after.
d477c27
to
fecba55
Compare
fecba55
to
c56b5d9
Compare
* main: feat(i18n): add `Astro.currentLocale` (withastro#9101) [ci] release (withastro#9107) Add compatibility with cloudflare node (withastro#8925) [ci] format Cancel response stream when connection closes (withastro#9071) [ci] format feat(i18n): apply specific routing logic only to pages (withastro#9091) feat(dev-overlay): Hide plugins into a separate menu when there's too many enabled (withastro#9102) [ci] format Support Svelte 5 (experimental) (withastro#9098) [ci] release (withastro#9078) [ci] format Refactor shikiji syntax highlighting code (withastro#9083) [ci] format fix: Query params trigger the trailingSlash error in preview mode (withastro#9045) fix(assets): bundling regression for specific config on non-Node runtimes (withastro#9087)
* See withastro/astro#4986 for `site`, `generator`, `url`, `clientAddress`, `props` and `redirect` * See withastro/astro#6721 for `locals` * See withastro/astro#9021 for `preferredLocale` and `preferredLocaleList` * See withastro/astro#9101 for `currentLocale`
* See withastro/astro#4986 for `site`, `generator`, `url`, `clientAddress`, `props` and `redirect` * See withastro/astro#6721 for `locals` * See withastro/astro#9021 for `preferredLocale` and `preferredLocaleList` * See withastro/astro#9101 for `currentLocale`
Changes
RFC change: withastro/roadmap@f934880
This PR adds a new
Astro.currentLocale
, which is computed fromRequest#url
,i18n.locales
,i18n.routingStrategy
andi18n.defaultLocale
If the routing strategy is
prefix-other-locales
, for any URL that doesn't contain a locale, we return thedefaultLocale
.This PR adds a bunch of data that we pass down the rendering of the page/endpoint, very similar to the same work I did when implementing
preferredLocale
.Closes PLT-1207
Testing
I added new test cases that should cover new use cases.
Docs
withastro/docs#5410
/cc @withastro/maintainers-docs for feedback!