I've recently had a problem with Java locales in my system, and I was trying to run a project with this configuration:
-Duser.language=pt_BR
-Duser.country=BR
After googling, I found this site which had me changing my configuration to:
-Duser.language=pt
-Duser.region=BR
-Duser.country=BR
And the problem was gone. Additionaly I've found pages like this talking about using another property called user.variant
.
I'm not after LC_* properties, I'm just trying to find out what's the difference between these four properties?
user.language
user.region
user.country
user.variant
Thanks
getDefault(Locale.Category category) Gets the current value of the default locale for the specified Category for this instance of the Java Virtual Machine. String. getDisplayCountry() Returns a name for the locale's country that is appropriate for display to the user.
A Locale is the mechanism for identifying the kind of object ( NumberFormat ) that you would like to get. The locale is just a mechanism for identifying objects, not a container for the objects themselves.
[loˈkale ] adjective. local. (treno) stopping (British) ⧫ local (US)
Locale Class is used to perform locale task and provides locale information for the user. Constructors : Locale(String L): Creates Locale form the given language code. Locale(String L, String C): Creates Locale form the given language, country code.
Please take a look at the javadoc of Locale
http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html
It describes language, variant, and so on.
If one day the link above breaks...
Copy pasted from https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html
ISO 639 alpha-2 or alpha-3 language code, or registered language subtags up to 8 alpha letters (for future enhancements). When a language has both an alpha-2 code and an alpha-3 code, the alpha-2 code must be used. You can find a full list of valid language codes in the IANA Language Subtag Registry (search for "Type: language"). The language field is case insensitive, but Locale always canonicalizes to lower case. Well-formed language values have the form [a-zA-Z]{2,8}. Note that this is not the the full BCP47 language production, since it excludes extlang. They are not needed since modern three-letter language codes replace them. Example: "en" (English), "ja" (Japanese), "kok" (Konkani)
ISO 3166 alpha-2 country code or UN M.49 numeric-3 area code. You can find a full list of valid country and region codes in the IANA Language Subtag Registry (search for "Type: region"). The country (region) field is case insensitive, but Locale always canonicalizes to upper case. Well-formed country/region values have the form [a-zA-Z]{2} | [0-9]{3} Example: "US" (United States), "FR" (France), "029" (Caribbean)
Any arbitrary value used to indicate a variation of a Locale. Where there are two or more variant values each indicating its own semantics, these values should be ordered by importance, with most important first, separated by underscore('_'). The variant field is case sensitive.
Note: IETF BCP 47 places syntactic restrictions on variant subtags. Also BCP 47 subtags are strictly used to indicate additional variations that define a language or its dialects that are not covered by any combinations of language, script and region subtags. You can find a full list of valid variant codes in the IANA Language Subtag Registry (search for "Type: variant").
However, the variant field in Locale has historically been used for any kind of variation, not just language variations. For example, some supported variants available in Java SE Runtime Environments indicate alternative cultural behaviors such as calendar type or number script. In BCP 47 this kind of information, which does not identify the language, is supported by extension subtags or private use subtags.
Well-formed variant values have the form SUBTAG (('_'|'-') SUBTAG)* where SUBTAG = [0-9][0-9a-zA-Z]{3} | [0-9a-zA-Z]{5,8}. (Note: BCP 47 only uses hyphen ('-') as a delimiter, this is more lenient).
Example: "polyton" (Polytonic Greek), "POSIX"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With