feat(web): enable app locales and add language toggle#1356
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Promote ready content locales into routing and add a LocaleToggle beside ThemeToggle on marketing and in the app shell. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Greptile SummaryThis PR enables more app locales and adds a language switcher. The main changes are:
Confidence Score: 5/5This looks safe to merge after a small locale-toggle cleanup.
apps/hyperlocalise-web/src/components/locale-toggle/locale-toggle.tsx
|
| Filename | Overview |
|---|---|
| apps/hyperlocalise-web/src/components/locale-toggle/locale-toggle.tsx | Adds the client language dropdown and locale-switch navigation. |
| apps/hyperlocalise-web/src/lib/app-i18n/rewrite-app-locale-path.ts | Adds helpers for reading and rewriting app locale prefixes. |
| apps/hyperlocalise-web/src/lib/app-i18n/locales.ts | Expands supported app locales to match available content locales. |
| apps/hyperlocalise-web/src/app/[lang]/(marketing)/_components/navbar.tsx | Adds the language toggle next to the existing theme controls. |
| apps/hyperlocalise-web/src/components/app-shell/app-shell-client.tsx | Adds the language toggle to the authenticated app shell header. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/hyperlocalise-web/src/components/locale-toggle/locale-toggle.tsx:65
**Mixed Router And Window State**
When the user changes language during or immediately after a client-side navigation, `pathname` can come from the App Router state while `window.location.search` and `window.location.hash` still come from the current browser URL. That can combine the next route with stale query or hash state, so the language toggle can navigate to the wrong localized URL or preserve filters/anchors from the previous page.
Reviews (1): Last reviewed commit: "feat(web): enable app locales and add la..." | Re-trigger Greptile
|
|
||
| const search = typeof window !== "undefined" ? window.location.search : ""; | ||
| const hash = typeof window !== "undefined" ? window.location.hash : ""; | ||
| router.push(rewriteAppLocalePath(`${pathname}${search}${hash}`, nextLocale)); |
There was a problem hiding this comment.
When the user changes language during or immediately after a client-side navigation, pathname can come from the App Router state while window.location.search and window.location.hash still come from the current browser URL. That can combine the next route with stale query or hash state, so the language toggle can navigate to the wrong localized URL or preserve filters/anchors from the previous page.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/hyperlocalise-web/src/components/locale-toggle/locale-toggle.tsx
Line: 65
Comment:
**Mixed Router And Window State**
When the user changes language during or immediately after a client-side navigation, `pathname` can come from the App Router state while `window.location.search` and `window.location.hash` still come from the current browser URL. That can combine the next route with stale query or hash state, so the language toggle can navigate to the wrong localized URL or preserve filters/anchors from the previous page.
How can I resolve this? If you propose a fix, please make it concise.
What changed
Promote ready content locales (
zh-CN,vi-VN,de-DE,fr-FR) intoSUPPORTED_APP_LOCALESso routing, cookies, sitemap, and robots cover them. Add aLocaleTogglebesideThemeToggleon the marketing navbar and in the app shell. Includes the approved ADR.How to test
/zh-CN/...,/vi-VN/...,/de-DE/...,/fr-FR/...routes resolvesitemap.xmlandrobots.txtinclude the new localesapps/hyperlocalise-web:vp test src/lib/app-i18n/andvp check --fixChecklist
vp check --fix; locale-relatedvp test)Made with Cursor