Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

en_US or en-US, which one should you use? [duplicate]

Assume you want to store the locale of user preference in database, which value you will use?

en_US or en-US

They are two standards, but which one you prefer to use as part of your own application?

Updated: Is seems many web sites use dash instead of underscore, e.g.

http://zh.wikipedia.org/zh-tw http://www.google.com.hk/search?hl=zh-TW

like image 412
Howard Avatar asked Feb 05 '11 02:02

Howard


People also ask

What does locale en us mean?

The construct Locale.US is equivalent to: new Locale("en", "US"); This particular Locale constructor requires two arguments: The language code and the country code for the Locale that you want to create. The language codes are lower-case, two-letter codes defined by ISO-639.

Why locale is used in Java?

A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user.

What is fr_FR?

French - FRANCE (FR) (fr_FR)

What is computer locale?

A locale consists of a number of categories for which country-dependent formatting or other specifications exist. A program's locale defines its code sets, date and time formatting conventions, monetary conventions, decimal formatting conventions, and collation (sort) order.


2 Answers

I'm pretty sure "-" is the standard. If you see "_" somewhere it's probably something some people came up with to make it a valid identifier.

Personally I'd go with "-", just to be correct.

http://en.wikipedia.org/wiki/IETF_language_tag

https://datatracker.ietf.org/doc/html/rfc5646

like image 91
Matti Virkkunen Avatar answered Sep 29 '22 07:09

Matti Virkkunen


If you're working with Java, you might as well use the Java locale format (en_US).

The BCP 47 documents actually do specify the en-US format, and it's just as common if not more common than Java-style locale names. But in practice you'll see the form with the underbar quite a bit. For example, both Java and most POSIX-type platforms use the underbar for their language/region separator.

So you can't go far wrong with either choice. But given that you're writing in Java and probably targeting a Unix platform, en_US is probably the way to go.

like image 45
dkarp Avatar answered Sep 29 '22 08:09

dkarp