为en-US和en_US创建语言环境有什么区别? [英] What is the difference between creating a locale for en-US and en_US?

查看:444
本文介绍了为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中,语言环境对象将语言识别为 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创建语言环境有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆