Skip to content
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

fix(i18n): fix regression in current locale #9998

Merged
merged 5 commits into from Feb 6, 2024

Conversation

ematipico
Copy link
Member

Changes

Closes #9970

I reverted the change to use pathname instead for RouteData::route..route contains the actual name of the file e.g. /blog/[...locale, which is not what I needed.

So, I reverted the code to use RouteData::pathname first and then URL::pathname in the former isn't present. RouteData::pathname covers SSR cases.

This PR also fixes another issue where Astro.currentLocale wasn't returning the correct value in case a locale is configured using the path property

Testing

I added new test cases.

Docs

N/A

Copy link

changeset-bot bot commented Feb 6, 2024

🦋 Changeset detected

Latest commit: 3f0c6f1

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Feb 6, 2024
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks good to me. A bit worried about the perf implication though since it has 3 nested loops, but we could revisit them next time. Also, is the two changesets intentional or should there only be one?

packages/astro/test/i18n-routing.test.js Outdated Show resolved Hide resolved
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
@ematipico
Copy link
Member Author

Also, is the two changesets intentional or should there only be one?

It's intentional, because the two bugs are unrelated (two different use cases), even though the function is the same.

.changeset/six-fishes-beg.md Outdated Show resolved Hide resolved
ematipico and others added 2 commits February 6, 2024 16:09
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
@ematipico ematipico merged commit 18ac094 into main Feb 6, 2024
4 checks passed
@ematipico ematipico deleted the fix/regression-current-locale-plt-1545 branch February 6, 2024 16:13
@astrobot-houston astrobot-houston mentioned this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version 4.2.7 breaks internacionalization of URLs when the locale is within rest parameters
2 participants