com.ibm.icu.util
public final class ULocale extends java.lang.Object implements java.io.Serializable
Locale
that provides additional
support for ICU protocol. In ICU 3.0 this class is enhanced to support
RFC 3066 language identifiers.
Many classes and services in ICU follow a factory idiom, in which a factory method or object responds to a client request with an object. The request includes a locale (the requested locale), and the returned object is constructed using data for that locale. The system may lack data for the requested locale, in which case the locale fallback mechanism will be invoked until a populated locale is found (the valid locale). Furthermore, even when a populated locale is found (the valid locale), further fallback may be required to reach a locale containing the specific data required by the service (the actual locale).
ULocale performs 'normalization' and 'canonicalization' of locale ids. Normalization 'cleans up' ICU locale ids as follows:
canonicalize
can be called to convert the id
to canonical form, or the canonicalInstance
factory method
can be called.
This class provides selectors VALID_LOCALE
and ACTUAL_LOCALE
intended for use in methods named
getLocale(). These methods exist in several ICU classes,
including Calendar
, Currency
, UFormat
,
BreakIterator
, Collator
, DateFormatSymbols
, and DecimalFormatSymbols
and their subclasses, if
any. Once an object of one of these classes has been created,
getLocale() may be called on it to determine the valid and
actual locale arrived at during the object's construction.
Note: The getLocale() method will be implemented in ICU 3.0; ICU 2.8 contains a partial preview implementation. The actual locale is returned correctly, but the valid locale is not, in most cases.
Locale
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
ULocale.Builder
Builder is used to build instances of Locale from values
configured by the setter.
|
static class |
ULocale.Type
Opaque selector enum for getLocale().
|
Modifier and Type | Field and Description |
---|---|
static ULocale.Type |
ACTUAL_LOCALE
Selector for getLocale() indicating the locale of the
resource containing the data.
|
static ULocale |
CANADA
Useful constant for country/region.
|
static ULocale |
CANADA_FRENCH
Useful constant for country/region.
|
static ULocale |
CHINA
Useful constant for country/region.
|
static ULocale |
CHINESE
Useful constant for language.
|
static ULocale |
ENGLISH
Useful constant for language.
|
static ULocale |
FRANCE
Useful constant for country/region.
|
static ULocale |
FRENCH
Useful constant for language.
|
static ULocale |
GERMAN
Useful constant for language.
|
static ULocale |
GERMANY
Useful constant for country/region.
|
static ULocale |
ITALIAN
Useful constant for language.
|
static ULocale |
ITALY
Useful constant for country/region.
|
static ULocale |
JAPAN
Useful constant for country/region.
|
static ULocale |
JAPANESE
Useful constant for language.
|
static ULocale |
KOREA
Useful constant for country/region.
|
static ULocale |
KOREAN
Useful constant for language.
|
static char |
LDML_EXTENSION
The key for LDML extension.
|
static ULocale |
PRC
Useful constant for country/region.
|
static char |
PRIVATE_USE_EXTENSION
The key for private use locale extension.
|
static ULocale |
ROOT
The root ULocale.
|
static ULocale |
SIMPLIFIED_CHINESE
Useful constant for language.
|
static ULocale |
TAIWAN
Useful constant for country/region.
|
static ULocale |
TRADITIONAL_CHINESE
Useful constant for language.
|
static ULocale |
UK
Useful constant for country/region.
|
static ULocale |
US
Useful constant for country/region.
|
static ULocale.Type |
VALID_LOCALE
Selector for getLocale() indicating the most specific
locale for which any data exists.
|
Constructor and Description |
---|
ULocale(java.lang.String localeID)
Construct a ULocale from a RFC 3066 locale ID.
|
ULocale(java.lang.String a,
java.lang.String b)
Convenience overload of ULocale(String, String, String) for
compatibility with java.util.Locale.
|
ULocale(java.lang.String a,
java.lang.String b,
java.lang.String c)
Construct a ULocale from a localeID constructed from the three 'fields' a, b, and c.
|
Modifier and Type | Method and Description |
---|---|
static ULocale |
acceptLanguage(java.lang.String acceptLanguageList,
boolean[] fallback)
Based on a HTTP formatted list of acceptable locales, determine an available locale for the user.
|
static ULocale |
acceptLanguage(java.lang.String acceptLanguageList,
ULocale[] availableLocales,
boolean[] fallback)
Based on a HTTP formatted list of acceptable locales, determine an available locale for the user.
|
static ULocale |
acceptLanguage(ULocale[] acceptLanguageList,
boolean[] fallback)
Based on an ordered array of acceptable locales, determine an available locale for the user.
|
static ULocale |
acceptLanguage(ULocale[] acceptLanguageList,
ULocale[] availableLocales,
boolean[] fallback)
Based on a list of acceptable locales, determine an available locale for the user.
|
static ULocale |
addLikelySubtags(ULocale loc)
Add the likely subtags for a provided locale ID, per the algorithm described
in the following CLDR technical report:
http://www.unicode.org/reports/tr35/#Likely_Subtags
If the provided ULocale instance is already in the maximal form, or there is no
data available available for maximization, it will be returned.
|
static java.lang.String |
canonicalize(java.lang.String localeID)
Returns the canonical name for the specified locale ID.
|
java.lang.Object |
clone()
This is for compatibility with Locale-- in actuality, since ULocale is
immutable, there is no reason to clone it, so this API returns 'this'.
|
static ULocale |
createCanonical(java.lang.String nonCanonicalID)
Create a ULocale from the id by first canonicalizing the id.
|
boolean |
equals(java.lang.Object obj)
Returns true if the other object is another ULocale with the
same full name, or is a String localeID that matches the full name.
|
static ULocale |
forLanguageTag(java.lang.String langtag)
Returns a locale for the specified language tag string.
|
static ULocale |
forLocale(java.util.Locale loc)
Return a ULocale object for a
Locale . |
static ULocale[] |
getAvailableLocales()
Returns a list of all installed locales.
|
java.lang.String |
getBaseName()
Returns the (normalized) base name for this locale.
|
static java.lang.String |
getBaseName(java.lang.String localeID)
Returns the (normalized) base name for the specified locale.
|
java.lang.String |
getCharacterOrientation()
Returns this locale's layout orientation for characters.
|
static VersionInfo |
getCLDRVersion()
Returns the current CLDR version
|
java.lang.String |
getCountry()
Returns the country/region code for this locale, which will either be the empty string
or an uppercase ISO 3166 2-letter code.
|
static java.lang.String |
getCountry(java.lang.String localeID)
Returns the country/region code for this locale, which will either be the empty string
or an uppercase ISO 3166 2-letter code.
|
static ULocale |
getDefault()
Returns the current default ULocale.
|
java.lang.String |
getDisplayCountry()
Returns this locale's country localized for display in the default locale.
|
static java.lang.String |
getDisplayCountry(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns a locale's country localized for display in the provided locale.
|
static java.lang.String |
getDisplayCountry(java.lang.String localeID,
ULocale displayLocale)
Returns a locale's country localized for display in the provided locale.
|
java.lang.String |
getDisplayCountry(ULocale displayLocale)
Returns this locale's country localized for display in the provided locale.
|
static java.lang.String |
getDisplayKeyword(java.lang.String keyword)
Returns a keyword localized for display in the default locale.
|
static java.lang.String |
getDisplayKeyword(java.lang.String keyword,
java.lang.String displayLocaleID)
Returns a keyword localized for display in the specified locale.
|
static java.lang.String |
getDisplayKeyword(java.lang.String keyword,
ULocale displayLocale)
Returns a keyword localized for display in the specified locale.
|
java.lang.String |
getDisplayKeywordValue(java.lang.String keyword)
Returns a keyword value localized for display in the default locale.
|
static java.lang.String |
getDisplayKeywordValue(java.lang.String localeID,
java.lang.String keyword,
java.lang.String displayLocaleID)
Returns a keyword value localized for display in the specified locale.
|
static java.lang.String |
getDisplayKeywordValue(java.lang.String localeID,
java.lang.String keyword,
ULocale displayLocale)
Returns a keyword value localized for display in the specified locale.
|
java.lang.String |
getDisplayKeywordValue(java.lang.String keyword,
ULocale displayLocale)
Returns a keyword value localized for display in the specified locale.
|
java.lang.String |
getDisplayLanguage()
Returns this locale's language localized for display in the default locale.
|
static java.lang.String |
getDisplayLanguage(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns a locale's language localized for display in the provided locale.
|
static java.lang.String |
getDisplayLanguage(java.lang.String localeID,
ULocale displayLocale)
Returns a locale's language localized for display in the provided locale.
|
java.lang.String |
getDisplayLanguage(ULocale displayLocale)
Returns this locale's language localized for display in the provided locale.
|
java.lang.String |
getDisplayName()
Returns this locale name localized for display in the default locale.
|
static java.lang.String |
getDisplayName(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns the locale ID localized for display in the provided locale.
|
static java.lang.String |
getDisplayName(java.lang.String localeID,
ULocale displayLocale)
Returns the locale ID localized for display in the provided locale.
|
java.lang.String |
getDisplayName(ULocale displayLocale)
Returns this locale name localized for display in the provided locale.
|
java.lang.String |
getDisplayScript()
Returns this locale's script localized for display in the default locale.
|
static java.lang.String |
getDisplayScript(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns a locale's script localized for display in the provided locale.
|
static java.lang.String |
getDisplayScript(java.lang.String localeID,
ULocale displayLocale)
Returns a locale's script localized for display in the provided locale.
|
java.lang.String |
getDisplayScript(ULocale displayLocale)
Returns this locale's script localized for display in the provided locale.
|
java.lang.String |
getDisplayVariant()
Returns this locale's variant localized for display in the default locale.
|
static java.lang.String |
getDisplayVariant(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns a locale's variant localized for display in the provided locale.
|
static java.lang.String |
getDisplayVariant(java.lang.String localeID,
ULocale displayLocale)
Returns a locale's variant localized for display in the provided locale.
|
java.lang.String |
getDisplayVariant(ULocale displayLocale)
Returns this locale's variant localized for display in the provided locale.
|
java.lang.String |
getExtension(char key)
Returns the extension associated with the specified extension key, or
null if there is no extension associated with the key.
|
java.util.Set |
getExtensionKeys()
Returns the set of extension keys associated with this locale, or null
if it has no extensions.
|
ULocale |
getFallback()
Returns the fallback locale for this locale.
|
static java.lang.String |
getFallback(java.lang.String localeID)
Returns the fallback locale for the specified locale, which might be the empty string.
|
java.lang.String |
getISO3Country()
Returns a three-letter abbreviation for this locale's country/region.
|
static java.lang.String |
getISO3Country(java.lang.String localeID)
Returns a three-letter abbreviation for this locale's country/region.
|
java.lang.String |
getISO3Language()
Returns a three-letter abbreviation for this locale's language.
|
static java.lang.String |
getISO3Language(java.lang.String localeID)
Returns a three-letter abbreviation for this locale's language.
|
static java.lang.String[] |
getISOCountries()
Returns a list of all 2-letter country codes defined in ISO 3166.
|
static java.lang.String[] |
getISOLanguages()
Returns a list of all 2-letter language codes defined in ISO 639.
|
java.util.Iterator |
getKeywords()
Returns an iterator over keywords for this locale.
|
static java.util.Iterator |
getKeywords(java.lang.String localeID)
Returns an iterator over keywords for the specified locale.
|
java.lang.String |
getKeywordValue(java.lang.String keywordName)
Returns the value for a keyword in this locale.
|
static java.lang.String |
getKeywordValue(java.lang.String localeID,
java.lang.String keywordName)
Returns the value for a keyword in the specified locale.
|
java.lang.String |
getLanguage()
Returns the language code for this locale, which will either be the empty string
or a lowercase ISO 639 code.
|
static java.lang.String |
getLanguage(java.lang.String localeID)
Returns the language code for the locale ID,
which will either be the empty string
or a lowercase ISO 639 code.
|
java.util.Set |
getLDMLExtensionKeys()
Returns the set of keys for LDML keywords defined by this locale, or
null if this locale has no locale extension.
|
java.lang.String |
getLDMLExtensionValue(java.lang.String key)
Returns the LDML keyword value ('type') associated with
the specified LDML key for this locale.
|
java.lang.String |
getLineOrientation()
Returns this locale's layout orientation for lines.
|
java.lang.String |
getName()
Returns the (normalized) full name for this locale.
|
static java.lang.String |
getName(java.lang.String localeID)
Returns the (normalized) full name for the specified locale.
|
java.lang.String |
getScript()
Returns the script code for this locale, which might be the empty string.
|
static java.lang.String |
getScript(java.lang.String localeID)
Returns the script code for the specified locale, which might be the empty string.
|
java.lang.String |
getVariant()
Returns the variant code for this locale, which might be the empty string.
|
static java.lang.String |
getVariant(java.lang.String localeID)
Returns the variant code for the specified locale, which might be the empty string.
|
int |
hashCode()
Returns the hashCode.
|
static ULocale |
minimizeSubtags(ULocale loc)
Minimize the subtags for a provided locale ID, per the algorithm described
in the following CLDR technical report:
http://www.unicode.org/reports/tr35/#Likely_Subtags
If the provided ULocale instance is already in the minimal form, or there
is no data available for minimization, it will be returned.
|
static void |
setDefault(ULocale newLocale)
Sets the default ULocale.
|
ULocale |
setKeywordValue(java.lang.String keyword,
java.lang.String value)
Given a keyword and a value, return a new locale with an updated
keyword and value.
|
static java.lang.String |
setKeywordValue(java.lang.String localeID,
java.lang.String keyword,
java.lang.String value)
Given a locale id, a keyword, and a value, return a new locale id with an updated
keyword and value.
|
java.lang.String |
toLanguageTag()
Returns a well-formed language tag representing this locale.
|
java.util.Locale |
toLocale()
Convert this ULocale object to a
Locale . |
java.lang.String |
toString()
Returns a string representation of this object.
|
public static final ULocale ENGLISH
public static final ULocale FRENCH
public static final ULocale GERMAN
public static final ULocale ITALIAN
public static final ULocale JAPANESE
public static final ULocale KOREAN
public static final ULocale CHINESE
public static final ULocale SIMPLIFIED_CHINESE
public static final ULocale TRADITIONAL_CHINESE
public static final ULocale FRANCE
public static final ULocale GERMANY
public static final ULocale ITALY
public static final ULocale JAPAN
public static final ULocale KOREA
public static final ULocale CHINA
public static final ULocale PRC
public static final ULocale TAIWAN
public static final ULocale UK
public static final ULocale US
public static final ULocale CANADA
public static final ULocale CANADA_FRENCH
public static final ULocale ROOT
public static ULocale.Type ACTUAL_LOCALE
public static ULocale.Type VALID_LOCALE
Note: The valid locale will be returned correctly in ICU 3.0 or later. In ICU 2.8, it is not returned correctly.
public static final char PRIVATE_USE_EXTENSION
public static final char LDML_EXTENSION
public ULocale(java.lang.String localeID)
This constructor does not canonicalize the localeID. So, for
example, "zh__pinyin" remains unchanged instead of converting
to "zh@collation=pinyin". By default ICU only recognizes the
latter as specifying pinyin collation. Use createCanonical(java.lang.String)
or canonicalize(java.lang.String)
if you need to canonicalize the localeID.
localeID
- string representation of the locale, e.g:
"en_US", "sy_Cyrl_YU", "zh__pinyin", "es_ES@currency=EUR;collation=traditional"public ULocale(java.lang.String a, java.lang.String b)
ULocale(String, String, String)
public ULocale(java.lang.String a, java.lang.String b, java.lang.String c)
ULocale(String localeID)
.
Java locale strings consisting of language, country, and variant will be handled by this form, since the country code (being shorter than four letters long) will not be interpreted as a script code. If a script code is present, the final argument ('c') will be interpreted as the country code. It is recommended that this constructor only be used to ease porting, and that clients instead use the single-argument constructor when constructing a ULocale from a localeID.
a
- first component of the locale idb
- second component of the locale idc
- third component of the locale idULocale(String)
public static ULocale forLocale(java.util.Locale loc)
Locale
.
The ULocale is canonicalized.loc
- a JDK localepublic static ULocale createCanonical(java.lang.String nonCanonicalID)
nonCanonicalID
- the locale id to canonicalizepublic java.util.Locale toLocale()
Locale
.public static ULocale getDefault()
public static void setDefault(ULocale newLocale)
newLocale
- the new default localejava.lang.SecurityException
- if a security manager exists and its
checkPermission
method doesn't allow the operation.java.lang.NullPointerException
- if newLocale
is nullSecurityManager.checkPermission(java.security.Permission)
,
PropertyPermission
public java.lang.Object clone()
clone
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public static ULocale[] getAvailableLocales()
public static VersionInfo getCLDRVersion()
public static java.lang.String[] getISOCountries()
public static java.lang.String[] getISOLanguages()
public java.lang.String getLanguage()
public static java.lang.String getLanguage(java.lang.String localeID)
public java.lang.String getScript()
getDisplayScript()
,
getDisplayScript(ULocale)
public static java.lang.String getScript(java.lang.String localeID)
getDisplayScript()
,
getDisplayScript(ULocale)
public java.lang.String getCountry()
public static java.lang.String getCountry(java.lang.String localeID)
localeID
- getDisplayCountry()
,
getDisplayCountry(ULocale)
public java.lang.String getVariant()
public static java.lang.String getVariant(java.lang.String localeID)
public static java.lang.String getFallback(java.lang.String localeID)
public ULocale getFallback()
public java.lang.String getBaseName()
public static java.lang.String getBaseName(java.lang.String localeID)
localeID
- the locale ID as a stringpublic java.lang.String getName()
public static java.lang.String getName(java.lang.String localeID)
localeID
- the localeID as a stringpublic java.lang.String toString()
toString
in class java.lang.Object
public java.util.Iterator getKeywords()
public static java.util.Iterator getKeywords(java.lang.String localeID)
public java.lang.String getKeywordValue(java.lang.String keywordName)
keywordName
- name of the keyword whose value is desired. Case insensitive.public static java.lang.String getKeywordValue(java.lang.String localeID, java.lang.String keywordName)
keywordName
- name of the keyword whose value is desired. Case insensitive.public static java.lang.String canonicalize(java.lang.String localeID)
localeID
- the locale idpublic ULocale setKeywordValue(java.lang.String keyword, java.lang.String value)
keyword
- the keyword to add/remove, or null to remove all keywords.value
- the value to add/set, or null to remove this particular keyword.public static java.lang.String setKeywordValue(java.lang.String localeID, java.lang.String keyword, java.lang.String value)
localeID
- the locale id to modifykeyword
- the keyword to add/remove, or null to remove all keywords.value
- the value to add/set, or null to remove this particular keyword.public java.lang.String getISO3Language()
ftp://dkuug.dk/i18n/iso-639-2.txt
java.util.MissingResourceException
- Throws MissingResourceException if the
three-letter language abbreviation is not available for this locale.public static java.lang.String getISO3Language(java.lang.String localeID)
ftp://dkuug.dk/i18n/iso-639-2.txt
java.util.MissingResourceException
- Throws MissingResourceException if the
three-letter language abbreviation is not available for this locale.public java.lang.String getISO3Country()
java.util.MissingResourceException
- Throws MissingResourceException if the
three-letter country abbreviation is not available for this locale.public static java.lang.String getISO3Country(java.lang.String localeID)
java.util.MissingResourceException
- Throws MissingResourceException if the
three-letter country abbreviation is not available for this locale.public java.lang.String getDisplayLanguage()
public java.lang.String getDisplayLanguage(ULocale displayLocale)
displayLocale
- the locale in which to display the name.public static java.lang.String getDisplayLanguage(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the id of the locale whose language will be displayeddisplayLocaleID
- the id of the locale in which to display the name.public static java.lang.String getDisplayLanguage(java.lang.String localeID, ULocale displayLocale)
localeID
- the id of the locale whose language will be displayed.displayLocale
- the locale in which to display the name.public java.lang.String getDisplayScript()
public java.lang.String getDisplayScript(ULocale displayLocale)
displayLocale
- the locale in which to display the name.public static java.lang.String getDisplayScript(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the id of the locale whose script will be displayeddisplayLocaleID
- the id of the locale in which to display the name.public static java.lang.String getDisplayScript(java.lang.String localeID, ULocale displayLocale)
localeID
- the id of the locale whose script will be displayed.displayLocale
- the locale in which to display the name.public java.lang.String getDisplayCountry()
public java.lang.String getDisplayCountry(ULocale displayLocale)
displayLocale
- the locale in which to display the name.public static java.lang.String getDisplayCountry(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the id of the locale whose country will be displayeddisplayLocaleID
- the id of the locale in which to display the name.public static java.lang.String getDisplayCountry(java.lang.String localeID, ULocale displayLocale)
localeID
- the id of the locale whose country will be displayed.displayLocale
- the locale in which to display the name.public java.lang.String getDisplayVariant()
public java.lang.String getDisplayVariant(ULocale displayLocale)
displayLocale
- the locale in which to display the name.public static java.lang.String getDisplayVariant(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the id of the locale whose variant will be displayeddisplayLocaleID
- the id of the locale in which to display the name.public static java.lang.String getDisplayVariant(java.lang.String localeID, ULocale displayLocale)
localeID
- the id of the locale whose variant will be displayed.displayLocale
- the locale in which to display the name.public static java.lang.String getDisplayKeyword(java.lang.String keyword)
keyword
- the keyword to be displayed.getKeywords()
public static java.lang.String getDisplayKeyword(java.lang.String keyword, java.lang.String displayLocaleID)
keyword
- the keyword to be displayed.displayLocaleID
- the id of the locale in which to display the keyword.getKeywords(String)
public static java.lang.String getDisplayKeyword(java.lang.String keyword, ULocale displayLocale)
keyword
- the keyword to be displayed.displayLocale
- the locale in which to display the keyword.getKeywords(String)
public java.lang.String getDisplayKeywordValue(java.lang.String keyword)
keyword
- the keyword whose value is to be displayed.public java.lang.String getDisplayKeywordValue(java.lang.String keyword, ULocale displayLocale)
keyword
- the keyword whose value is to be displayed.displayLocale
- the locale in which to display the value.public static java.lang.String getDisplayKeywordValue(java.lang.String localeID, java.lang.String keyword, java.lang.String displayLocaleID)
localeID
- the id of the locale whose keyword value is to be displayed.keyword
- the keyword whose value is to be displayed.displayLocaleID
- the id of the locale in which to display the value.public static java.lang.String getDisplayKeywordValue(java.lang.String localeID, java.lang.String keyword, ULocale displayLocale)
localeID
- the id of the locale whose keyword value is to be displayed.keyword
- the keyword whose value is to be displayed.displayLocale
- the id of the locale in which to display the value.public java.lang.String getDisplayName()
public java.lang.String getDisplayName(ULocale displayLocale)
displayLocale
- the locale in which to display the locale name.public static java.lang.String getDisplayName(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the locale whose name is to be displayed.displayLocaleID
- the id of the locale in which to display the locale name.public static java.lang.String getDisplayName(java.lang.String localeID, ULocale displayLocale)
localeID
- the locale whose name is to be displayed.displayLocale
- the locale in which to display the locale name.public java.lang.String getCharacterOrientation()
public java.lang.String getLineOrientation()
public static ULocale acceptLanguage(java.lang.String acceptLanguageList, ULocale[] availableLocales, boolean[] fallback)
acceptLanguageList
- list in HTTP "Accept-Language:" format of acceptable localesavailableLocales
- list of available locales. One of these will be returned.fallback
- if non-null, a 1-element array containing a boolean to be set with the fallback statuspublic static ULocale acceptLanguage(ULocale[] acceptLanguageList, ULocale[] availableLocales, boolean[] fallback)
acceptLanguageList
- list of acceptable localesavailableLocales
- list of available locales. One of these will be returned.fallback
- if non-null, a 1-element array containing a boolean to be set with the fallback statuspublic static ULocale acceptLanguage(java.lang.String acceptLanguageList, boolean[] fallback)
acceptLanguageList
- list in HTTP "Accept-Language:" format of acceptable localesfallback
- if non-null, a 1-element array containing a boolean to be set with the fallback statuspublic static ULocale acceptLanguage(ULocale[] acceptLanguageList, boolean[] fallback)
acceptLanguageList
- ordered array of acceptable locales (preferred are listed first)fallback
- if non-null, a 1-element array containing a boolean to be set with the fallback statuspublic static ULocale addLikelySubtags(ULocale loc)
loc
- The ULocale to maximizepublic static ULocale minimizeSubtags(ULocale loc)
loc
- The ULocale to minimizepublic java.lang.String getExtension(char key)
[0-9A-Za-z]
.
PRIVATE_USE_KEY
.
key
- the extension keyjava.lang.IllegalArgumentException
- if the key is not valid.PRIVATE_USE_EXTENSION
public java.util.Set getExtensionKeys()
public java.lang.String getLDMLExtensionValue(java.lang.String key)
key
- the LDML keyjava.lang.IllegalArgumentException
- if the key is not valid.public java.util.Set getLDMLExtensionKeys()
public java.lang.String toLanguageTag()
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.
public static ULocale forLanguageTag(java.lang.String langtag)
This implements the 'Language-Tag' production of BCP47, and so supports grandfathered (regular and irregular) as well as private use language tags. Private use tags are represented as 'und-x-whatever', and grandfathered tags are converted to their canonical replacements where they exist. Note that a few grandfathered tags have no modern replacement, these will be converted using the fallback described in the first paragraph, so some information might be lost.
For a list of grandfathered tags, see RFC4646 (Currently Draft, remove or reference final version before release.)
langtag
- the language tagCopyright (c) 2009 IBM Corporation and others.