Skip to content

fix: remove browser language based auto-redirect #3050

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

Closed

Conversation

dongzhenye
Copy link
Contributor

已知问题

  1. 多语言自动重定向逻辑不合理
    • 基于浏览器语言设置的自动重定向影响用户体验
    • 比如,我们使用英文浏览器访问默认语言为中文的根域名时,就会自动跳转到英文版本
    • 这就违背了用户访问根域名应该显示默认语言的预期

解决方案

  1. 简化语言选择逻辑
    • 移除基于浏览器语言设置的自动重定向
    • 通过注释明确定义语言选择的优先级规则
    • 保持对URL参数和路径前缀的支持

改动收益

  1. 更好的用户体验
    • 访问根域名时始终显示默认语言
    • 语言切换行为更可预测
    • 避免不必要的页面跳转

具体改动

  1. lib/lang.js
    • 移除window?.navigator?.language相关逻辑
    • 更新注释说明语言选择的优先级规则
    • 保持对 locale/lang URL参数的支持

测试确认

  • 本地开发环境测试通过

相关Issue/PR

这是对 #2926 的后续修复。

- Remove automatic language redirection based on browser settings
- Only redirect when language is explicitly specified in URL parameters
- Update comments to clarify language selection priority
Copy link

vercel bot commented Dec 9, 2024

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

Name Status Preview Comments Updated (UTC)
notion-next-home ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 2:40pm
notion-next-preview ✅ Ready (Inspect) Visit Preview Dec 9, 2024 2:40pm
notion-next-seo-lesson ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 2:40pm

Copy link

vercel bot commented Dec 9, 2024

@dongzhenye is attempting to deploy a commit to the tangly1024's projects Team on Vercel.

A member of the Team first needs to authorize it.

@dongzhenye
Copy link
Contributor Author

我发现这个修复方案还存在问题,在Vercel部署后没有解决问题。

为避免影响其他用户,我先关闭这个PR。等问题完全解决后会重新提交。

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.

1 participant