-
Notifications
You must be signed in to change notification settings - Fork 60.6k
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
一些语言无法与浏览器语言设置同步显示 [Bug] #4853
Comments
Title: Some languages cannot be displayed in sync with browser language settings [Bug] |
Can you provide the browser version and detailed user agent information? |
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0 |
这和浏览器版本可能没什么关系,只是在代码中 navigator.language 和 国际化 language code 并没有完全对应上,例如我上面的截图, navigator.language 为 ’zh‘ 时,并不能和代码中 ’cn‘ 匹配上,新用户显示的语言会回退到默认语言 DEFAULT_LANG = "en",还有一些语言也存在类似的情况 |
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language @DDDDD12138 |
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language @DDDDD12138 |
我观察到了这个区别,但同时项目中 getLanguage 方法默认 toLowerCase 返回了小写的字符,所以 #4855 这个 pr 中 lang 始终是小写的,就目前的情况,是可以解决与浏览器语言不同步的问题 |
I have observed this difference, but at the same time, the getLanguage method in the project returns lowercase characters by default toLowerCase, so lang in #4855 is always lowercase. As far as the current situation is concerned, it can solve the problem of being out of sync with the browser language. |
I noticed that this problem exists in many projects. There seems to be no relatively complete solution for mapping or best practices. For example, Hong Kong and Taiwan both use Traditional Chinese, which means that different languages may correspond to the same translation document. |
我经手的有一些项目,使用混合的策略:
|
Some of the projects I've worked on have used a mix of strategies:
|
感谢老哥的建议!我本想基于你的建议做一些修改。 |
Thanks for the advice bro! I wanted to make some changes based on your suggestions.
|
我想,这里是不是应该改成合理的方式,再针对旧数据做一下兼容? |
I think, should we change this to a reasonable way and make compatibility with the old data? |
或者使用另一个API去处理这个事情,而不是依赖字符串比较或者手工去添加一堆兼容的map https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/minimize 可能是一个比较好的兼容处理的方案:
以下部分展示了不同格式的language使用
|
Taught, I have closed what I mentioned before |
受教了,我已经把之前提的关闭了 |
Bug Description
我的浏览器设置为中文,但是默认显示的却是英文内容。
例如:将浏览器语言设置为中文或日文,却默认显示为英文内容,
若设置为英文或者法文,可以正确显示对应的内容
Steps to Reproduce
Expected Behavior
浏览器语言为中文是,默认显示为中文
Screenshots
Deployment Method
Desktop OS
Windows 10
Desktop Browser
Edge, Chrome
Desktop Browser Version
126
Smartphone Device
No response
Smartphone OS
No response
Smartphone Browser
No response
Smartphone Browser Version
No response
Additional Logs
No response
The text was updated successfully, but these errors were encountered: