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

Add language selector #540

Merged
merged 2 commits into from
Aug 24, 2024
Merged

Add language selector #540

merged 2 commits into from
Aug 24, 2024

Conversation

sruenwg
Copy link
Collaborator

@sruenwg sruenwg commented Aug 23, 2024

Closes #432, closes #536.

What this PR solves / how to test:

Changes

  • Added language selector to drawer
  • Configured middleware so that the user is directed to the first valid locale found in: URL locale > NEXT_LOCALE cookie > Accept-Language header (e.g. en-GB would send the user to /en) > default locale (ja).

Tests

  • Changing the locale with the language selector adds a new entry to the browser history with the selected locale
  • The NEXT_LOCALE cookie and the language shown in the language selector are always in sync with the URL locale
    • Browser forward/back updates all three items correctly
  • First visit (empty cookies) to / redirects to:
    • /en/schedule/all if the browser locale (the Accept-Language header sent) has en* set to a higher priority than ja*
    • /ja/schedule/all otherwise
  • Manually entering a URL with a locale overrides any previous cookie set

@sruenwg sruenwg requested a review from sugar-cat7 as a code owner August 23, 2024 15:24
Copy link

vercel bot commented Aug 23, 2024

@sruenwg is attempting to deploy a commit to the sugar-cat7's Team Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Aug 23, 2024

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

Name Status Preview Updated (UTC)
vspo-schedule ✅ Ready (Inspect) Visit Preview Aug 23, 2024 10:17pm

Copy link
Owner

@sugar-cat7 sugar-cat7 left a comment

Choose a reason for hiding this comment

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

Wow, thank you! It's perfect!!

@sruenwg sruenwg merged commit 1c9d7e0 into sugar-cat7:main Aug 24, 2024
4 checks passed
@sruenwg sruenwg deleted the locale-selector branch August 28, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants