Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
265 views
in Technique[技术] by (71.8m points)

java - What is the difference between creating a locale for en-US and en_US?

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.

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?

question from:https://stackoverflow.com/questions/4632885/what-is-the-difference-between-creating-a-locale-for-en-us-and-en-us

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

"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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...