Skip to content

Conversation

@NebraskaCoder
Copy link
Member

Summary

  • Disable localeDetection in middleware to prevent Accept-Language header reading
  • Add setRequestLocale() to layout and all pages for static rendering
  • Add generateStaticParams() to layout for pre-generating locale paths
  • Convert useTranslations to getTranslations in page components
  • Wrap TabsClient in Suspense boundary for useSearchParams compatibility

Problem

Users experience random language switching on page refresh due to the interaction between:

  1. next-intl's localeDetection: true reading the Accept-Language header
  2. Next.js marking pages as dynamic when headers() is called
  3. Vercel's edge cache not properly caching dynamic pages

Solution

Disable automatic locale detection and enable static rendering so each locale path (/download, /zh-TW/download, etc.) is cached independently.

Documentation

See docs/i18n/caching-and-locale-detection.md for full technical details.

Test plan

  • Build passes with static generation for all locale pages
  • Lint passes
  • Deploy to Vercel preview and verify:
    • X-Vercel-Cache shows HIT on subsequent requests
    • No random locale switching on refresh
    • Language picker still works correctly
  • Test all affected pages render correctly

🤖 Generated with Claude Code

Changes:
- Disable localeDetection in middleware to prevent Accept-Language header reading
- Add setRequestLocale() to layout and all pages for static rendering
- Add generateStaticParams() to layout for pre-generating locale paths
- Convert useTranslations to getTranslations in page components
- Wrap TabsClient in Suspense boundary for useSearchParams compatibility

This fixes the random locale switching issue on Vercel by allowing
pages to be statically generated and cached per locale path.

See: docs/i18n/caching-and-locale-detection.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@vercel
Copy link

vercel bot commented Nov 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rockylinux-org Ready Ready Preview Comment Nov 28, 2025 9:36pm

@NebraskaCoder
Copy link
Member Author

This PR will require testing before merging.

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.

2 participants