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

feat(core): add locale switcher to Header #1907

Merged
merged 3 commits into from
Jan 14, 2025
Merged

Conversation

jorgemoya
Copy link
Contributor

@jorgemoya jorgemoya commented Jan 14, 2025

What/Why?

Add locale switcher to the Header, using server action and redirect. In this use case we need to revalidate the / to make sure the cookies get updated with the new locale. We also had to workaround an issue by redirecting to the /en when the default locale is used.

Testing

Locale switcher works as expected.

Kapture.2025-01-14.at.11.50.02.mp4

@jorgemoya jorgemoya requested a review from a team as a code owner January 14, 2025 17:50
Copy link

changeset-bot bot commented Jan 14, 2025

⚠️ No Changeset found

Latest commit: 9fd43e0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jan 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
catalyst-canary ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 9:12pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
catalyst ⬜️ Ignored (Inspect) Jan 14, 2025 9:12pm
catalyst-au ⬜️ Ignored (Inspect) Visit Preview Jan 14, 2025 9:12pm
catalyst-soul ⬜️ Ignored (Inspect) Visit Preview Jan 14, 2025 9:12pm
catalyst-uk ⬜️ Ignored (Inspect) Visit Preview Jan 14, 2025 9:12pm

@jorgemoya jorgemoya changed the title Add locale switcher feat(core): add locale switcher to Header Jan 14, 2025
Copy link
Contributor

@bookernath bookernath left a comment

Choose a reason for hiding this comment

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

Tested this, LGTM ✅

Comment on lines 23 to 27

if (submission.value.id === defaultLocale) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just add a comment why we need to do this.

Suggested change
if (submission.value.id === defaultLocale) {
// Since `redirect` doesn't prepend the local to the redirect url
// when navigating the a default locale link, we need to prepend
// it ourselves to ensure the redirect happens.
if (submission.value.id === defaultLocale) {

@jorgemoya jorgemoya force-pushed the add-locale-switcher branch from a0ed3c8 to 9fd43e0 Compare January 14, 2025 21:09
@jorgemoya jorgemoya added this pull request to the merge queue Jan 14, 2025
Merged via the queue into canary with commit 072dd18 Jan 14, 2025
8 checks passed
@jorgemoya jorgemoya deleted the add-locale-switcher branch January 14, 2025 21:50
bookernath pushed a commit that referenced this pull request Jan 17, 2025
* feat(core): add locale switcher to Header

* fix: add translation for error

* chore: add context comment
BC-krasnoshapka pushed a commit that referenced this pull request Jan 23, 2025
* feat(core): add locale switcher to Header

* fix: add translation for error

* chore: add context comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants