fix: support lowercase regional locale routes - #209
Conversation
|
@laaichiu is attempting to deploy a commit to the Spree Commerce Team on Vercel. A member of the Team first needs to authorize it. |
Strix Security ReviewNo security issues found. Updated for Reviewed by Strix |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe change adds canonical regional-locale normalization. Routing, market locale resolution, layout handling, region preferences, country switching, middleware, and tests now use lowercase route locales such as ChangesRegional locale normalization
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant RegionPreferences
participant useCountrySwitch
participant Cart
participant Cookies
participant Router
RegionPreferences->>useCountrySwitch: select country with en-GB
useCountrySwitch->>Cart: update locale to en-gb
useCountrySwitch->>Cookies: store en-gb
useCountrySwitch->>Router: navigate to /gb/en-gb/products
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/hooks/useCountrySwitch.ts`:
- Around line 43-51: Update the early-return condition in useCountrySwitch so it
also verifies that the cart locale is the canonical lowercase target locale
before returning true; preserve the update flow for legacy values such as en-GB
so cart, cookies, and navigation persist en-gb. Add a regression test covering
an en-GB cart on the gb/en-gb route.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8f01f1c5-f864-4dcf-bdd2-51582f7ba79d
📒 Files selected for processing (12)
src/app/[country]/[locale]/layout.test.tsxsrc/components/layout/RegionPreferences.tsxsrc/components/layout/__tests__/RegionPreferences.test.tsxsrc/hooks/__tests__/useCountrySwitch.test.tssrc/hooks/useCountrySwitch.tssrc/i18n/__tests__/locales.test.tssrc/i18n/__tests__/markets.test.tssrc/i18n/__tests__/routing.test.tssrc/i18n/locales.tssrc/i18n/normalize.tssrc/i18n/routing.tssrc/lib/spree/middleware.test.ts
Closes #208
Thanks for reporting this. We traced the two behaviors to different causes:
GB /
en-GBThe Market accepted
en-GB, but the storefront only hadenregistered in its locale registry. As a result, the regional route was rejected and could lead to a 404. We now support the lowercase route localeen-gbwhile reusing the existingmessages/en.jsonbundle./gb/en-GBis canonicalized to/gb/en-gb.JP /
jaThe Japan Market is configured with
ja, but the storefront currently does not include a Japanese message bundle. Market configuration alone does not make a locale renderable by the storefront, so unsupportedjarequests safely redirect to the configured default route/us/en. This is expected behavior.To serve Japan in Japanese, we need to add and register
messages/ja.json. If Japan should use English for now, the Market default locale should be set toenwhile keeping Japan’s country and currency settings.Summary by CodeRabbit
New Features
Bug Fixes