What is the difference between user.region, user.language, user.country and user.variant?

I recently had a problem with Java locales on my system, and I tried to run a project with this configuration:

-Duser.language=pt_BR -Duser.country=BR 

After googling, I found this site , because of which I changed my configuration to:

 -Duser.language=pt -Duser.region=BR -Duser.country=BR 

And the problem has disappeared. Also, I found pages like this , talking about using another property called user.variant .

I'm not following the properties of LC_ *, I'm just trying to figure out what is the difference between these four properties?

 user.language user.region user.country user.variant 

thanks

+6
source share
2 answers

Please take a look at javadoc Locale http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html

It describes the language, variant, etc.

+5
source

If one day the link above is broken ...

Copy from https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html

user.language

ISO 639 alpha-2 or alpha-3 language code or registered language subtags of up to 8 alpha letters (for future improvements). If the language has both an alpha-2 code and an alpha-3 code, use the alpha-2 code. You can find the complete list of valid language codes in the IANA language sub-tag registry (search for "Type: language"). The language field is case-insensitive, but Locale always canonizes lowercase. Well-formed language meanings have the form [a-zA-Z] {2,8}. Please note that this is not the full language of the BCP47 language, as it excludes extlang. They are not needed, since modern three-letter language codes replace them. Example: "en" (English), "ja" (Japanese), "kok" (Konkani)

user.region / user.country

ISO 3166 country code alpha-2 or M.49 code with number-3 at the UN. A complete list of the correct country and region codes can be found in the IANA subtitle registry (search for "Type: region"). The field of a country (region) is not case sensitive, but Locale is always canonically upper case. Well-formed country / region values โ€‹โ€‹take the form [a-zA-Z] {2} | [0-9] {3} Example: "USA" (USA), "FR" (France), "029" (Caribbean)

user.variant

Any arbitrary value used to indicate Locale variation. If there are two or more variants of values, each of which indicates its own semantics, these values โ€‹โ€‹should be ordered by importance, and it is most important to first separate them with an underscore ('_'). The variant field is case sensitive.

Note. The IETF BCP 47 places syntactic restrictions on subtags variants. BCP 47 subtitles are also strictly used to indicate additional variations that define a language or its dialects that are not covered by any combination of language, script, and sub-bytes of the region. You can find the full list of valid variant codes in the IANA sub-tag register (search for "Type: variant").

However, the variant field in Locale has historically been used for any variants, and not just for language variations. For example, some of the supported options available in Java SE Runtime Environments indicate alternative cultural behavior, such as a calendar type or script number. In BCP 47, such information that does not identify the language is supported by extension subtitles or parts of private use.

Well-formed variants 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 a hyphen ('-') as a delimiter, this is milder).

Example: "polytonic", "POSIX"

0
source

Source: https://habr.com/ru/post/954261/


All Articles