What is the difference between creating a locale for en-US and en_US?(为 en-US 和 en_US 创建语言环境有什么区别?)
问题描述
我的所有 ResourceBundle
值都在一个表格中,并根据要求进行了格式化.我必须根据页面顶部下拉菜单中的用户选择更改网站上的语言.
I have all my ResourceBundle
values in a table and formatted as per requirement. I have to change the languages on the website based on user selection in a dropdown at the top of the page.
如果我使用诸如 en_US
之类的语言代码,那么它可以正常工作.如果我使用 en-US
作为语言代码,则它不起作用.可能是什么问题?这样做的正确方法是什么?
If I use a language code such as en_US
, then it works fine. If I use en-US
as a language code, then it doesn't work. What might be the problem? Which is the correct way to do this?
推荐答案
en"是ISO 639指定的语言代码.而US是3166指定的国家代码.
在 Java 中,Locale 对象将语言识别为 languageCode_countryCode(例如 en_US)而不是 languageCode-countryCode.
"en" is the language code specified by ISO 639. while US is country code specified by 3166.
In Java, the Locale object recognizes the language as languageCode_countryCode (e.g. en_US) and not as languageCode-countryCode.
这篇关于为 en-US 和 en_US 创建语言环境有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为 en-US 和 en_US 创建语言环境有什么区别?


基础教程推荐
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01