Note: If the language, country, or variant fields do not satisfy BCP47 language tag syntax requirements, they are omitted from the result. For example, using the constructor it is possible to create a Locale instance with digits in the language field, or only two characters in the variant field. Since these are not well-formed BCP47 language tag syntax, they cannot be expressed in BCP47. Since such 'legacy' locales lose information when converting to BCP47, it is recommended that clients switch to conforming locales.
Note: Underscores in the variant tag are normalized to hyphen, and all fields, keys, and values are normalized to lower case. @return a BCP47 language tag representing the locale. @draft ICU 4.2 @provisional This API might change or be removed in a future release.
If this Locale
has a language, country, or variant that does not satisfy the IETF BCP 47 language tag syntax requirements, this method handles these fields as described below:
Language: If language is empty, or not well-formed (for example "a" or "e2"), it will be emitted as "und" (Undetermined).
Country: If country is not well-formed (for example "12" or "USA"), it will be omitted.
Variant: If variant is well-formed, each sub-segment (delimited by '-' or '_') is emitted as a subtag. Otherwise:
[0-9a-zA-Z]{1,8}
(for example "WIN" or "Oracle_JDK_Standard_Edition"), the first ill-formed sub-segment and all following will be appended to the private use subtag. The first appended subtag will be "lvariant", followed by the sub-segments in order, separated by hyphen. For example, "x-lvariant-WIN", "Oracle-x-lvariant-JDK-Standard-Edition". [0-9a-zA-Z]{1,8}
, the variant will be truncated and the problematic sub-segment and all following sub-segments will be omitted. If the remainder is non-empty, it will be emitted as a private use subtag as above (even if the remainder turns out to be well-formed). For example, "Solaris_isjustthecoolestthing" is emitted as "x-lvariant-Solaris", not as "solaris".Special Conversions: Java supports some old locale representations, including deprecated ISO language codes, for compatibility. This method performs the following conversions:
Note: Although the language tag created by this method is well-formed (satisfies the syntax requirements defined by the IETF BCP 47 specification), it is not necessarily a valid BCP 47 language tag. For example,
new Locale("xx", "YY").toLanguageTag();will return "xx-YY", but the language subtag "xx" and the region subtag "YY" are invalid because they are not registered in the IANA Language Subtag Registry. @return a BCP47 language tag representing the locale @see #forLanguageTag(String) @since 1.7
|
|
|
|
|
|
|
|
|
|
|
|