com.ibm.icu.util
Class ULocale

java.lang.Object
  extended by com.ibm.icu.util.ULocale
All Implemented Interfaces:
Serializable

public final class ULocale
extends Object
implements Serializable

[icu enhancement] ICU's replacement for java.util.Locale. Methods, fields, and other functionality specific to ICU are labeled '[icu]'.

A class analogous to 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:

Canonicalization additionally performs the following: All ULocale constructors automatically normalize the locale id. To handle POSIX ids, 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 actual locale is returned correctly, but the valid locale is not, in most cases.

Author:
weiv, Alan Liu, Ram Viswanadha
See Also:
Locale, Serialized Form
Status:
Stable ICU 2.8.

Nested Class Summary
static class ULocale.Builder
          Builder is used to build instances of ULocale from values configured by the setters.
static class ULocale.Category
          Enum for locale categories.
static class ULocale.Type
          Opaque selector enum for getLocale().
 
Field Summary
static ULocale.Type ACTUAL_LOCALE
          [icu] 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 ULocale PRC
          Useful constant for country/region.
static char PRIVATE_USE_EXTENSION
          [icu] The key for the private use locale extension ('x').
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 char UNICODE_LOCALE_EXTENSION
          [icu] The key for Unicode locale extension ('u').
static ULocale US
          Useful constant for country/region.
static ULocale.Type VALID_LOCALE
          [icu] Selector for getLocale() indicating the most specific locale for which any data exists.
 
Constructor Summary
ULocale(String localeID)
          [icu] Constructs a ULocale from a RFC 3066 locale ID.
ULocale(String a, String b)
          Convenience overload of ULocale(String, String, String) for compatibility with java.util.Locale.
ULocale(String a, String b, String c)
          Constructs a ULocale from a localeID constructed from the three 'fields' a, b, and c.
 
Method Summary
static ULocale acceptLanguage(String acceptLanguageList, boolean[] fallback)
          [icu] Based on a HTTP formatted list of acceptable locales, determine an available locale for the user.
static ULocale acceptLanguage(String acceptLanguageList, ULocale[] availableLocales, boolean[] fallback)
          [icu] Based on a HTTP formatted list of acceptable locales, determine an available locale for the user.
static ULocale acceptLanguage(ULocale[] acceptLanguageList, boolean[] fallback)
          [icu] Based on an ordered array of acceptable locales, determine an available locale for the user.
static ULocale acceptLanguage(ULocale[] acceptLanguageList, ULocale[] availableLocales, boolean[] fallback)
          [icu] Based on a list of acceptable locales, determine an available locale for the user.
static ULocale addLikelySubtags(ULocale loc)
          [icu] Adds 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 String canonicalize(String localeID)
          [icu] Returns the canonical name for the specified locale ID.
 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(String nonCanonicalID)
          [icu] Creates a ULocale from the id by first canonicalizing the id.
 boolean equals(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(String languageTag)
          [icu] Returns a locale for the specified IETF BCP 47 language tag string.
static ULocale forLocale(Locale loc)
          [icu] Returns a ULocale object for a Locale.
static ULocale[] getAvailableLocales()
          

[icu] Note: Unlike the Locale API, this returns an array of ULocale, not Locale.

 String getBaseName()
          [icu] Returns the (normalized) base name for this locale.
static String getBaseName(String localeID)
          [icu] Returns the (normalized) base name for the specified locale.
 String getCharacterOrientation()
          [icu] Returns this locale's layout orientation for characters.
 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 String getCountry(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.
static ULocale getDefault(ULocale.Category category)
          Returns the current default ULocale for the specified category.
 String getDisplayCountry()
          Returns this locale's country localized for display in the default DISPLAY locale.
static String getDisplayCountry(String localeID, String displayLocaleID)
          Returns a locale's country localized for display in the provided locale.
static String getDisplayCountry(String localeID, ULocale displayLocale)
          Returns a locale's country localized for display in the provided locale.
 String getDisplayCountry(ULocale displayLocale)
          Returns this locale's country localized for display in the provided locale.
static String getDisplayKeyword(String keyword)
          [icu] Returns a keyword localized for display in the default DISPLAY locale.
static String getDisplayKeyword(String keyword, String displayLocaleID)
          [icu] Returns a keyword localized for display in the specified locale.
static String getDisplayKeyword(String keyword, ULocale displayLocale)
          [icu] Returns a keyword localized for display in the specified locale.
 String getDisplayKeywordValue(String keyword)
          [icu] Returns a keyword value localized for display in the default DISPLAY locale.
static String getDisplayKeywordValue(String localeID, String keyword, String displayLocaleID)
          [icu] Returns a keyword value localized for display in the specified locale.
static String getDisplayKeywordValue(String localeID, String keyword, ULocale displayLocale)
          [icu] Returns a keyword value localized for display in the specified locale.
 String getDisplayKeywordValue(String keyword, ULocale displayLocale)
          [icu] Returns a keyword value localized for display in the specified locale.
 String getDisplayLanguage()
          Returns this locale's language localized for display in the default DISPLAY locale.
static String getDisplayLanguage(String localeID, String displayLocaleID)
          Returns a locale's language localized for display in the provided locale.
static String getDisplayLanguage(String localeID, ULocale displayLocale)
          Returns a locale's language localized for display in the provided locale.
 String getDisplayLanguage(ULocale displayLocale)
          [icu] Returns this locale's language localized for display in the provided locale.
 String getDisplayLanguageWithDialect()
          [icu] Returns this locale's language localized for display in the default DISPLAY locale.
static String getDisplayLanguageWithDialect(String localeID, String displayLocaleID)
          [icu] Returns a locale's language localized for display in the provided locale.
static String getDisplayLanguageWithDialect(String localeID, ULocale displayLocale)
          [icu] Returns a locale's language localized for display in the provided locale.
 String getDisplayLanguageWithDialect(ULocale displayLocale)
          [icu] Returns this locale's language localized for display in the provided locale.
 String getDisplayName()
          Returns this locale name localized for display in the default DISPLAY locale.
static String getDisplayName(String localeID, String displayLocaleID)
          Returns the locale ID localized for display in the provided locale.
static String getDisplayName(String localeID, ULocale displayLocale)
          Returns the locale ID localized for display in the provided locale.
 String getDisplayName(ULocale displayLocale)
          Returns this locale name localized for display in the provided locale.
 String getDisplayNameWithDialect()
          [icu] Returns this locale name localized for display in the default DISPLAY locale.
static String getDisplayNameWithDialect(String localeID, String displayLocaleID)
          [icu] Returns the locale ID localized for display in the provided locale.
static String getDisplayNameWithDialect(String localeID, ULocale displayLocale)
          [icu] Returns the locale ID localized for display in the provided locale.
 String getDisplayNameWithDialect(ULocale displayLocale)
          [icu] Returns this locale name localized for display in the provided locale.
 String getDisplayScript()
          [icu] Returns this locale's script localized for display in the default DISPLAY locale.
static String getDisplayScript(String localeID, String displayLocaleID)
          [icu] Returns a locale's script localized for display in the provided locale.
static String getDisplayScript(String localeID, ULocale displayLocale)
          [icu] Returns a locale's script localized for display in the provided locale.
 String getDisplayScript(ULocale displayLocale)
          [icu] Returns this locale's script localized for display in the provided locale.
 String getDisplayVariant()
          Returns this locale's variant localized for display in the default DISPLAY locale.
static String getDisplayVariant(String localeID, String displayLocaleID)
          Returns a locale's variant localized for display in the provided locale.
static String getDisplayVariant(String localeID, ULocale displayLocale)
          Returns a locale's variant localized for display in the provided locale.
 String getDisplayVariant(ULocale displayLocale)
          Returns this locale's variant localized for display in the provided locale.
 String getExtension(char key)
          [icu] Returns the extension (or private use) value associated with the specified key, or null if there is no extension associated with the key.
 Set<Character> getExtensionKeys()
          [icu] Returns the set of extension keys associated with this locale, or the empty set if it has no extensions.
 ULocale getFallback()
          [icu] Returns the fallback locale for this locale.
static String getFallback(String localeID)
          [icu] Returns the fallback locale for the specified locale, which might be the empty string.
 String getISO3Country()
          Returns a three-letter abbreviation for this locale's country/region.
static String getISO3Country(String localeID)
          Returns a three-letter abbreviation for this locale's country/region.
 String getISO3Language()
          Returns a three-letter abbreviation for this locale's language.
static String getISO3Language(String localeID)
          Returns a three-letter abbreviation for this locale's language.
static String[] getISOCountries()
          Returns a list of all 2-letter country codes defined in ISO 3166.
static String[] getISOLanguages()
          Returns a list of all 2-letter language codes defined in ISO 639.
 Iterator<String> getKeywords()
          [icu] Returns an iterator over keywords for this locale.
static Iterator<String> getKeywords(String localeID)
          [icu] Returns an iterator over keywords for the specified locale.
 String getKeywordValue(String keywordName)
          [icu] Returns the value for a keyword in this locale.
static String getKeywordValue(String localeID, String keywordName)
          [icu] Returns the value for a keyword in the specified locale.
 String getLanguage()
          Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.
static String getLanguage(String localeID)
          Returns the language code for the locale ID, which will either be the empty string or a lowercase ISO 639 code.
 String getLineOrientation()
          [icu] Returns this locale's layout orientation for lines.
 String getName()
          [icu] Returns the (normalized) full name for this locale.
static String getName(String localeID)
          [icu] Returns the (normalized) full name for the specified locale.
 String getScript()
          [icu] Returns the script code for this locale, which might be the empty string.
static String getScript(String localeID)
          [icu] Returns the script code for the specified locale, which might be the empty string.
 Set<String> getUnicodeLocaleAttributes()
          [icu] Returns the set of unicode locale attributes associated with this locale, or the empty set if it has no attributes.
 Set<String> getUnicodeLocaleKeys()
          [icu] Returns the set of Unicode locale keys defined by this locale, or the empty set if this locale has none.
 String getUnicodeLocaleType(String key)
          [icu] Returns the Unicode locale type associated with the specified Unicode locale key for this locale.
 String getVariant()
          Returns the variant code for this locale, which might be the empty string.
static String getVariant(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)
          [icu] Minimizes 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.Category category, ULocale newLocale)
          Sets the default ULocale for the specified Category.
static void setDefault(ULocale newLocale)
          [icu] Sets the default ULocale.
 ULocale setKeywordValue(String keyword, String value)
          Given a keyword and a value, return a new locale with an updated keyword and value.
static String setKeywordValue(String localeID, String keyword, String value)
          Given a locale id, a keyword, and a value, return a new locale id with an updated keyword and value.
 String toLanguageTag()
          [icu] Returns a well-formed IETF BCP 47 language tag representing this locale.
 Locale toLocale()
          [icu] Converts this ULocale object to a Locale.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ENGLISH

public static final ULocale ENGLISH
Useful constant for language.

Status:
Stable ICU 3.0.

FRENCH

public static final ULocale FRENCH
Useful constant for language.

Status:
Stable ICU 3.0.

GERMAN

public static final ULocale GERMAN
Useful constant for language.

Status:
Stable ICU 3.0.

ITALIAN

public static final ULocale ITALIAN
Useful constant for language.

Status:
Stable ICU 3.0.

JAPANESE

public static final ULocale JAPANESE
Useful constant for language.

Status:
Stable ICU 3.0.

KOREAN

public static final ULocale KOREAN
Useful constant for language.

Status:
Stable ICU 3.0.

CHINESE

public static final ULocale CHINESE
Useful constant for language.

Status:
Stable ICU 3.0.

SIMPLIFIED_CHINESE

public static final ULocale SIMPLIFIED_CHINESE
Useful constant for language.

Status:
Stable ICU 3.0.

TRADITIONAL_CHINESE

public static final ULocale TRADITIONAL_CHINESE
Useful constant for language.

Status:
Stable ICU 3.0.

FRANCE

public static final ULocale FRANCE
Useful constant for country/region.

Status:
Stable ICU 3.0.

GERMANY

public static final ULocale GERMANY
Useful constant for country/region.

Status:
Stable ICU 3.0.

ITALY

public static final ULocale ITALY
Useful constant for country/region.

Status:
Stable ICU 3.0.

JAPAN

public static final ULocale JAPAN
Useful constant for country/region.

Status:
Stable ICU 3.0.

KOREA

public static final ULocale KOREA
Useful constant for country/region.

Status:
Stable ICU 3.0.

CHINA

public static final ULocale CHINA
Useful constant for country/region.

Status:
Stable ICU 3.0.

PRC

public static final ULocale PRC
Useful constant for country/region.

Status:
Stable ICU 3.0.

TAIWAN

public static final ULocale TAIWAN
Useful constant for country/region.

Status:
Stable ICU 3.0.

UK

public static final ULocale UK
Useful constant for country/region.

Status:
Stable ICU 3.0.

US

public static final ULocale US
Useful constant for country/region.

Status:
Stable ICU 3.0.

CANADA

public static final ULocale CANADA
Useful constant for country/region.

Status:
Stable ICU 3.0.

CANADA_FRENCH

public static final ULocale CANADA_FRENCH
Useful constant for country/region.

Status:
Stable ICU 3.0.

ROOT

public static final ULocale ROOT
The root ULocale.

Status:
Stable ICU 2.8.

ACTUAL_LOCALE

public static ULocale.Type ACTUAL_LOCALE
[icu] Selector for getLocale() indicating the locale of the resource containing the data. This is always at or above the valid locale. If the valid locale does not contain the specific data being requested, then the actual locale will be above the valid locale. If the object was not constructed from locale data, then the valid locale is null.

Status:
Draft ICU 2.8 (retain).

VALID_LOCALE

public static ULocale.Type VALID_LOCALE
[icu] Selector for getLocale() indicating the most specific locale for which any data exists. This is always at or above the requested locale, and at or below the actual locale. If the requested locale does not correspond to any resource data, then the valid locale will be above the requested locale. If the object was not constructed from locale data, then the actual locale is null.

Note: The valid locale will be returned correctly in ICU 3.0 or later. In ICU 2.8, it is not returned correctly.

Status:
Draft ICU 2.8 (retain).

PRIVATE_USE_EXTENSION

public static final char PRIVATE_USE_EXTENSION
[icu] The key for the private use locale extension ('x').

See Also:
getExtension(char), ULocale.Builder.setExtension(char, String), Constant Field Values
Status:
Draft ICU 4.2.

UNICODE_LOCALE_EXTENSION

public static final char UNICODE_LOCALE_EXTENSION
[icu] The key for Unicode locale extension ('u').

See Also:
getExtension(char), ULocale.Builder.setExtension(char, String), Constant Field Values
Status:
Draft ICU 4.2.
Constructor Detail

ULocale

public ULocale(String localeID)
[icu] Constructs a ULocale from a RFC 3066 locale ID. The locale ID consists of optional language, script, country, and variant fields in that order, separated by underscores, followed by an optional keyword list. The script, if present, is four characters long-- this distinguishes it from a country code, which is two characters long. Other fields are distinguished by position as indicated by the underscores. The start of the keyword list is indicated by '@', and consists of two or more keyword/value pairs separated by semicolons(';').

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.

Parameters:
localeID - string representation of the locale, e.g: "en_US", "sy_Cyrl_YU", "zh__pinyin", "es_ES@currency=EUR;collation=traditional"
Status:
Stable ICU 2.8.

ULocale

public ULocale(String a,
               String b)
Convenience overload of ULocale(String, String, String) for compatibility with java.util.Locale.

See Also:
ULocale(String, String, String)
Status:
Stable ICU 3.4.

ULocale

public ULocale(String a,
               String b,
               String c)
Constructs a ULocale from a localeID constructed from the three 'fields' a, b, and c. These fields are concatenated using underscores to form a localeID of the form a_b_c, which is then handled like the localeID passed to 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.

Parameters:
a - first component of the locale id
b - second component of the locale id
c - third component of the locale id
See Also:
ULocale(String)
Status:
Stable ICU 3.0.
Method Detail

forLocale

public static ULocale forLocale(Locale loc)
[icu] Returns a ULocale object for a Locale. The ULocale is canonicalized.

Parameters:
loc - a JDK locale
Status:
Stable ICU 3.2.

createCanonical

public static ULocale createCanonical(String nonCanonicalID)
[icu] Creates a ULocale from the id by first canonicalizing the id.

Parameters:
nonCanonicalID - the locale id to canonicalize
Returns:
the locale created from the canonical version of the ID.
Status:
Stable ICU 3.0.

toLocale

public Locale toLocale()
[icu] Converts this ULocale object to a Locale.

Returns:
a JDK locale that either exactly represents this object or is the closest approximation.
Status:
Stable ICU 2.8.

getDefault

public static ULocale getDefault()
Returns the current default ULocale.

Returns:
the default ULocale.
Status:
Stable ICU 2.8.

setDefault

public static void setDefault(ULocale newLocale)
[icu] Sets the default ULocale. This also sets the default Locale. If the caller does not have write permission to the user.language property, a security exception will be thrown, and the default ULocale will remain unchanged.

By setting the default ULocale with this method, all of the default categoy locales are also set to the specified default ULocale.

Parameters:
newLocale - the new default locale
Throws:
SecurityException - if a security manager exists and its checkPermission method doesn't allow the operation.
NullPointerException - if newLocale is null
See Also:
SecurityManager.checkPermission(java.security.Permission), PropertyPermission, setDefault(Category, ULocale)
Status:
Stable ICU 3.0.

getDefault

public static ULocale getDefault(ULocale.Category category)
Returns the current default ULocale for the specified category.

Parameters:
category - the category
Returns:
the default ULocale for the specified category.
Status:
Stable ICU 49.

setDefault

public static void setDefault(ULocale.Category category,
                              ULocale newLocale)
Sets the default ULocale for the specified Category. This also sets the default Locale for the specified Category of the JVM. If the caller does not have write permission to the user.language property, a security exception will be thrown, and the default ULocale for the specified Category will remain unchanged.

Parameters:
category - the specified category to set the default locale
newLocale - the new default locale
See Also:
SecurityManager.checkPermission(java.security.Permission), PropertyPermission
Status:
Stable ICU 49.

clone

public 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'.

Overrides:
clone in class Object
Status:
Stable ICU 3.0.

hashCode

public int hashCode()
Returns the hashCode.

Overrides:
hashCode in class Object
Status:
Stable ICU 3.0.

equals

public boolean equals(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. Note that since names are not canonicalized, two ULocales that function identically might not compare equal.

Overrides:
equals in class Object
Returns:
true if this Locale is equal to the specified object.
Status:
Stable ICU 3.0.

getAvailableLocales

public static ULocale[] getAvailableLocales()

[icu] Note: Unlike the Locale API, this returns an array of ULocale, not Locale. Returns a list of all installed locales.

Status:
Stable ICU 3.0.

getISOCountries

public static String[] getISOCountries()
Returns a list of all 2-letter country codes defined in ISO 3166. Can be used to create Locales.

Status:
Stable ICU 3.0.

getISOLanguages

public static String[] getISOLanguages()
Returns a list of all 2-letter language codes defined in ISO 639. Can be used to create Locales. [NOTE: ISO 639 is not a stable standard-- some languages' codes have changed. The list this function returns includes both the new and the old codes for the languages whose codes have changed.]

Status:
Stable ICU 3.0.

getLanguage

public String getLanguage()
Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.

See Also:
getDisplayLanguage(), getDisplayLanguage(ULocale)
Status:
Stable ICU 3.0.

getLanguage

public static String getLanguage(String localeID)
Returns the language code for the locale ID, which will either be the empty string or a lowercase ISO 639 code.

See Also:
getDisplayLanguage(), getDisplayLanguage(ULocale)
Status:
Stable ICU 3.0.

getScript

public String getScript()
[icu] Returns the script code for this locale, which might be the empty string.

See Also:
getDisplayScript(), getDisplayScript(ULocale)
Status:
Stable ICU 3.0.

getScript

public static String getScript(String localeID)
[icu] Returns the script code for the specified locale, which might be the empty string.

See Also:
getDisplayScript(), getDisplayScript(ULocale)
Status:
Stable ICU 3.0.

getCountry

public 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.

See Also:
getDisplayCountry(), getDisplayCountry(ULocale)
Status:
Stable ICU 3.0.

getCountry

public static String getCountry(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.

Parameters:
localeID - The locale identification string.
See Also:
getDisplayCountry(), getDisplayCountry(ULocale)
Status:
Stable ICU 3.0.

getVariant

public String getVariant()
Returns the variant code for this locale, which might be the empty string.

See Also:
getDisplayVariant(), getDisplayVariant(ULocale)
Status:
Stable ICU 3.0.

getVariant

public static String getVariant(String localeID)
Returns the variant code for the specified locale, which might be the empty string.

See Also:
getDisplayVariant(), getDisplayVariant(ULocale)
Status:
Stable ICU 3.0.

getFallback

public static String getFallback(String localeID)
[icu] Returns the fallback locale for the specified locale, which might be the empty string.

Status:
Stable ICU 3.2.

getFallback

public ULocale getFallback()
[icu] Returns the fallback locale for this locale. If this locale is root, returns null.

Status:
Stable ICU 3.2.

getBaseName

public String getBaseName()
[icu] Returns the (normalized) base name for this locale.

Returns:
the base name as a String.
Status:
Stable ICU 3.0.

getBaseName

public static String getBaseName(String localeID)
[icu] Returns the (normalized) base name for the specified locale.

Parameters:
localeID - the locale ID as a string
Returns:
the base name as a String.
Status:
Stable ICU 3.0.

getName

public String getName()
[icu] Returns the (normalized) full name for this locale.

Returns:
String the full name of the localeID
Status:
Stable ICU 3.0.

getName

public static String getName(String localeID)
[icu] Returns the (normalized) full name for the specified locale.

Parameters:
localeID - the localeID as a string
Returns:
String the full name of the localeID
Status:
Stable ICU 3.0.

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Status:
Stable ICU 3.0.

getKeywords

public Iterator<String> getKeywords()
[icu] Returns an iterator over keywords for this locale. If there are no keywords, returns null.

Returns:
iterator over keywords, or null if there are no keywords.
Status:
Stable ICU 3.0.

getKeywords

public static Iterator<String> getKeywords(String localeID)
[icu] Returns an iterator over keywords for the specified locale. If there are no keywords, returns null.

Returns:
an iterator over the keywords in the specified locale, or null if there are no keywords.
Status:
Stable ICU 3.0.

getKeywordValue

public String getKeywordValue(String keywordName)
[icu] Returns the value for a keyword in this locale. If the keyword is not defined, returns null.

Parameters:
keywordName - name of the keyword whose value is desired. Case insensitive.
Returns:
the value of the keyword, or null.
Status:
Stable ICU 3.0.

getKeywordValue

public static String getKeywordValue(String localeID,
                                     String keywordName)
[icu] Returns the value for a keyword in the specified locale. If the keyword is not defined, returns null. The locale name does not need to be normalized.

Parameters:
keywordName - name of the keyword whose value is desired. Case insensitive.
Returns:
String the value of the keyword as a string
Status:
Stable ICU 3.0.

canonicalize

public static String canonicalize(String localeID)
[icu] Returns the canonical name for the specified locale ID. This is used to convert POSIX and other grandfathered IDs to standard ICU form.

Parameters:
localeID - the locale id
Returns:
the canonicalized id
Status:
Stable ICU 3.0.

setKeywordValue

public ULocale setKeywordValue(String keyword,
                               String value)
Given a keyword and a value, return a new locale with an updated keyword and value. If keyword is null, this removes all keywords from the locale id. Otherwise, if the value is null, this removes the value for this keyword from the locale id. Otherwise, this adds/replaces the value for this keyword in the locale id. The keyword and value must not be empty.

Parameters:
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.
Returns:
the updated locale
Status:
Stable ICU 3.2.

setKeywordValue

public static String setKeywordValue(String localeID,
                                     String keyword,
                                     String value)
Given a locale id, a keyword, and a value, return a new locale id with an updated keyword and value. If keyword is null, this removes all keywords from the locale id. Otherwise, if the value is null, this removes the value for this keyword from the locale id. Otherwise, this adds/replaces the value for this keyword in the locale id. The keyword and value must not be empty.

Parameters:
localeID - the locale id to modify
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.
Returns:
the updated locale id
Status:
Stable ICU 3.2.

getISO3Language

public String getISO3Language()
Returns a three-letter abbreviation for this locale's language. If the locale doesn't specify a language, returns the empty string. Otherwise, returns a lowercase ISO 639-2/T language code. The ISO 639-2 language codes can be found on-line at ftp://dkuug.dk/i18n/iso-639-2.txt

Throws:
MissingResourceException - Throws MissingResourceException if the three-letter language abbreviation is not available for this locale.
Status:
Stable ICU 3.0.

getISO3Language

public static String getISO3Language(String localeID)
Returns a three-letter abbreviation for this locale's language. If the locale doesn't specify a language, returns the empty string. Otherwise, returns a lowercase ISO 639-2/T language code. The ISO 639-2 language codes can be found on-line at ftp://dkuug.dk/i18n/iso-639-2.txt

Throws:
MissingResourceException - Throws MissingResourceException if the three-letter language abbreviation is not available for this locale.
Status:
Stable ICU 3.0.

getISO3Country

public String getISO3Country()
Returns a three-letter abbreviation for this locale's country/region. If the locale doesn't specify a country, returns the empty string. Otherwise, returns an uppercase ISO 3166 3-letter country code.

Throws:
MissingResourceException - Throws MissingResourceException if the three-letter country abbreviation is not available for this locale.
Status:
Stable ICU 3.0.

getISO3Country

public static String getISO3Country(String localeID)
Returns a three-letter abbreviation for this locale's country/region. If the locale doesn't specify a country, returns the empty string. Otherwise, returns an uppercase ISO 3166 3-letter country code.

Throws:
MissingResourceException - Throws MissingResourceException if the three-letter country abbreviation is not available for this locale.
Status:
Stable ICU 3.0.

getDisplayLanguage

public String getDisplayLanguage()
Returns this locale's language localized for display in the default DISPLAY locale.

Returns:
the localized language name.
See Also:
ULocale.Category.DISPLAY
Status:
Stable ICU 3.0.

getDisplayLanguage

public String getDisplayLanguage(ULocale displayLocale)
[icu] Returns this locale's language localized for display in the provided locale.

Parameters:
displayLocale - the locale in which to display the name.
Returns:
the localized language name.
Status:
Stable ICU 3.0.

getDisplayLanguage

public static String getDisplayLanguage(String localeID,
                                        String displayLocaleID)
Returns a locale's language localized for display in the provided locale. This is a cover for the ICU4C API.

Parameters:
localeID - the id of the locale whose language will be displayed
displayLocaleID - the id of the locale in which to display the name.
Returns:
the localized language name.
Status:
Stable ICU 3.0.

getDisplayLanguage

public static String getDisplayLanguage(String localeID,
                                        ULocale displayLocale)
Returns a locale's language localized for display in the provided locale. This is a cover for the ICU4C API.

Parameters:
localeID - the id of the locale whose language will be displayed.
displayLocale - the locale in which to display the name.
Returns:
the localized language name.
Status:
Stable ICU 3.0.

getDisplayLanguageWithDialect

public String getDisplayLanguageWithDialect()
[icu] Returns this locale's language localized for display in the default DISPLAY locale. If a dialect name is present in the data, then it is returned.

Returns:
the localized language name.
See Also:
ULocale.Category.DISPLAY
Status:
Stable ICU 4.4.

getDisplayLanguageWithDialect

public String getDisplayLanguageWithDialect(ULocale displayLocale)
[icu] Returns this locale's language localized for display in the provided locale. If a dialect name is present in the data, then it is returned.

Parameters:
displayLocale - the locale in which to display the name.
Returns:
the localized language name.
Status:
Stable ICU 4.4.

getDisplayLanguageWithDialect

public static String getDisplayLanguageWithDialect(String localeID,
                                                   String displayLocaleID)
[icu] Returns a locale's language localized for display in the provided locale. If a dialect name is present in the data, then it is returned. This is a cover for the ICU4C API.

Parameters:
localeID - the id of the locale whose language will be displayed
displayLocaleID - the id of the locale in which to display the name.
Returns:
the localized language name.
Status:
Stable ICU 4.4.

getDisplayLanguageWithDialect

public static String getDisplayLanguageWithDialect(String localeID,
                                                   ULocale displayLocale)
[icu] Returns a locale's language localized for display in the provided locale. If a dialect name is present in the data, then it is returned. This is a cover for the ICU4C API.

Parameters:
localeID - the id of the locale whose language will be displayed.
displayLocale - the locale in which to display the name.
Returns:
the localized language name.
Status:
Stable ICU 4.4.

getDisplayScript

public String getDisplayScript()
[icu] Returns this locale's script localized for display in the default DISPLAY locale.

Returns:
the localized script name.
See Also:
ULocale.Category.DISPLAY
Status:
Stable ICU 3.0.

getDisplayScript

public String getDisplayScript(ULocale displayLocale)
[icu] Returns this locale's script localized for display in the provided locale.

Parameters:
displayLocale - the locale in which to display the name.
Returns:
the localized script name.
Status:
Stable ICU 3.0.

getDisplayScript

public static String getDisplayScript(String localeID,
                                      String displayLocaleID)
[icu] Returns a locale's script localized for display in the provided locale. This is a cover for the ICU4C API.

Parameters:
localeID - the id of the locale whose script will be displayed
displayLocaleID - the id of the locale in which to display the name.
Returns:
the localized script name.
Status:
Stable ICU 3.0.

getDisplayScript

public static String getDisplayScript(String localeID,
                                      ULocale displayLocale)
[icu] Returns a locale's script localized for display in the provided locale.

Parameters:
localeID - the id of the locale whose script will be displayed.
displayLocale - the locale in which to display the name.
Returns:
the localized script name.
Status:
Stable ICU 3.0.

getDisplayCountry

public String getDisplayCountry()
Returns this locale's country localized for display in the default DISPLAY locale.

Returns:
the localized country name.
See Also:
ULocale.Category.DISPLAY
Status:
Stable ICU 3.0.

getDisplayCountry

public String getDisplayCountry(ULocale displayLocale)
Returns this locale's country localized for display in the provided locale.

Parameters:
displayLocale - the locale in which to display the name.
Returns:
the localized country name.
Status:
Stable ICU 3.0.

getDisplayCountry

public static String getDisplayCountry(String localeID,
                                       String displayLocaleID)
Returns a locale's country localized for display in the provided locale. This is a cover for the ICU4C API.

Parameters:
localeID - the id of the locale whose country will be displayed
displayLocaleID - the id of the locale in which to display the name.
Returns:
the localized country name.
Status:
Stable ICU 3.0.

getDisplayCountry

public static String getDisplayCountry(String localeID,
                                       ULocale displayLocale)
Returns a locale's country localized for display in the provided locale. This is a cover for the ICU4C API.

Parameters:
localeID - the id of the locale whose country will be displayed.
displayLocale - the locale in which to display the name.
Returns:
the localized country name.
Status:
Stable ICU 3.0.

getDisplayVariant

public String getDisplayVariant()
Returns this locale's variant localized for display in the default DISPLAY locale.

Returns:
the localized variant name.
See Also:
ULocale.Category.DISPLAY
Status:
Stable ICU 3.0.

getDisplayVariant

public String getDisplayVariant(ULocale displayLocale)
Returns this locale's variant localized for display in the provided locale.

Parameters:
displayLocale - the locale in which to display the name.
Returns:
the localized variant name.
Status:
Stable ICU 3.0.

getDisplayVariant

public static String getDisplayVariant(String localeID,
                                       String displayLocaleID)
Returns a locale's variant localized for display in the provided locale. This is a cover for the ICU4C API.

Parameters:
localeID - the id of the locale whose variant will be displayed
displayLocaleID - the id of the locale in which to display the name.
Returns:
the localized variant name.
Status:
Stable ICU 3.0.

getDisplayVariant

public static String getDisplayVariant(String localeID,
                                       ULocale displayLocale)
Returns a locale's variant localized for display in the provided locale. This is a cover for the ICU4C API.

Parameters:
localeID - the id of the locale whose variant will be displayed.
displayLocale - the locale in which to display the name.
Returns:
the localized variant name.
Status:
Stable ICU 3.0.

getDisplayKeyword

public static String getDisplayKeyword(String keyword)
[icu] Returns a keyword localized for display in the default DISPLAY locale.

Parameters:
keyword - the keyword to be displayed.
Returns:
the localized keyword name.
See Also:
getKeywords(), ULocale.Category.DISPLAY
Status:
Stable ICU 3.0.

getDisplayKeyword

public static String getDisplayKeyword(String keyword,
                                       String displayLocaleID)
[icu] Returns a keyword localized for display in the specified locale.

Parameters:
keyword - the keyword to be displayed.
displayLocaleID - the id of the locale in which to display the keyword.
Returns:
the localized keyword name.
See Also:
getKeywords(String)
Status:
Stable ICU 3.0.

getDisplayKeyword

public static String getDisplayKeyword(String keyword,
                                       ULocale displayLocale)
[icu] Returns a keyword localized for display in the specified locale.

Parameters:
keyword - the keyword to be displayed.
displayLocale - the locale in which to display the keyword.
Returns:
the localized keyword name.
See Also:
getKeywords(String)
Status:
Stable ICU 3.0.

getDisplayKeywordValue

public String getDisplayKeywordValue(String keyword)
[icu] Returns a keyword value localized for display in the default DISPLAY locale.

Parameters:
keyword - the keyword whose value is to be displayed.
Returns:
the localized value name.
See Also:
ULocale.Category.DISPLAY
Status:
Stable ICU 3.0.

getDisplayKeywordValue

public String getDisplayKeywordValue(String keyword,
                                     ULocale displayLocale)
[icu] Returns a keyword value localized for display in the specified locale.

Parameters:
keyword - the keyword whose value is to be displayed.
displayLocale - the locale in which to display the value.
Returns:
the localized value name.
Status:
Stable ICU 3.0.

getDisplayKeywordValue

public static String getDisplayKeywordValue(String localeID,
                                            String keyword,
                                            String displayLocaleID)
[icu] Returns a keyword value localized for display in the specified locale. This is a cover for the ICU4C API.

Parameters:
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.
Returns:
the localized value name.
Status:
Stable ICU 3.0.

getDisplayKeywordValue

public static String getDisplayKeywordValue(String localeID,
                                            String keyword,
                                            ULocale displayLocale)
[icu] Returns a keyword value localized for display in the specified locale. This is a cover for the ICU4C API.

Parameters:
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.
Returns:
the localized value name.
Status:
Stable ICU 3.0.

getDisplayName

public String getDisplayName()
Returns this locale name localized for display in the default DISPLAY locale.

Returns:
the localized locale name.
See Also:
ULocale.Category.DISPLAY
Status:
Stable ICU 3.0.

getDisplayName

public String getDisplayName(ULocale displayLocale)
Returns this locale name localized for display in the provided locale.

Parameters:
displayLocale - the locale in which to display the locale name.
Returns:
the localized locale name.
Status:
Stable ICU 3.0.

getDisplayName

public static String getDisplayName(String localeID,
                                    String displayLocaleID)
Returns the locale ID localized for display in the provided locale. This is a cover for the ICU4C API.

Parameters:
localeID - the locale whose name is to be displayed.
displayLocaleID - the id of the locale in which to display the locale name.
Returns:
the localized locale name.
Status:
Stable ICU 3.0.

getDisplayName

public static String getDisplayName(String localeID,
                                    ULocale displayLocale)
Returns the locale ID localized for display in the provided locale. This is a cover for the ICU4C API.

Parameters:
localeID - the locale whose name is to be displayed.
displayLocale - the locale in which to display the locale name.
Returns:
the localized locale name.
Status:
Stable ICU 3.0.

getDisplayNameWithDialect

public String getDisplayNameWithDialect()
[icu] Returns this locale name localized for display in the default DISPLAY locale. If a dialect name is present in the locale data, then it is returned.

Returns:
the localized locale name.
See Also:
ULocale.Category.DISPLAY
Status:
Stable ICU 4.4.

getDisplayNameWithDialect

public String getDisplayNameWithDialect(ULocale displayLocale)
[icu] Returns this locale name localized for display in the provided locale. If a dialect name is present in the locale data, then it is returned.

Parameters:
displayLocale - the locale in which to display the locale name.
Returns:
the localized locale name.
Status:
Stable ICU 4.4.

getDisplayNameWithDialect

public static String getDisplayNameWithDialect(String localeID,
                                               String displayLocaleID)
[icu] Returns the locale ID localized for display in the provided locale. If a dialect name is present in the locale data, then it is returned. This is a cover for the ICU4C API.

Parameters:
localeID - the locale whose name is to be displayed.
displayLocaleID - the id of the locale in which to display the locale name.
Returns:
the localized locale name.
Status:
Stable ICU 4.4.

getDisplayNameWithDialect

public static String getDisplayNameWithDialect(String localeID,
                                               ULocale displayLocale)
[icu] Returns the locale ID localized for display in the provided locale. If a dialect name is present in the locale data, then it is returned. This is a cover for the ICU4C API.

Parameters:
localeID - the locale whose name is to be displayed.
displayLocale - the locale in which to display the locale name.
Returns:
the localized locale name.
Status:
Stable ICU 4.4.

getCharacterOrientation

public String getCharacterOrientation()
[icu] Returns this locale's layout orientation for characters. The possible values are "left-to-right", "right-to-left", "top-to-bottom" or "bottom-to-top".

Returns:
The locale's layout orientation for characters.
Status:
Stable ICU 4.0.

getLineOrientation

public String getLineOrientation()
[icu] Returns this locale's layout orientation for lines. The possible values are "left-to-right", "right-to-left", "top-to-bottom" or "bottom-to-top".

Returns:
The locale's layout orientation for lines.
Status:
Stable ICU 4.0.

acceptLanguage

public static ULocale acceptLanguage(String acceptLanguageList,
                                     ULocale[] availableLocales,
                                     boolean[] fallback)
[icu] Based on a HTTP formatted list of acceptable locales, determine an available locale for the user. NullPointerException is thrown if acceptLanguageList or availableLocales is null. If fallback is non-null, it will contain true if a fallback locale (one not in the acceptLanguageList) was returned. The value on entry is ignored. ULocale will be one of the locales in availableLocales, or the ROOT ULocale if if a ROOT locale was used as a fallback (because nothing else in availableLocales matched). No ULocale array element should be null; behavior is undefined if this is the case.

Parameters:
acceptLanguageList - list in HTTP "Accept-Language:" format of acceptable locales
availableLocales - 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 status
Returns:
one of the locales from the availableLocales list, or null if none match
Status:
Stable ICU 3.4.

acceptLanguage

public static ULocale acceptLanguage(ULocale[] acceptLanguageList,
                                     ULocale[] availableLocales,
                                     boolean[] fallback)
[icu] Based on a list of acceptable locales, determine an available locale for the user. NullPointerException is thrown if acceptLanguageList or availableLocales is null. If fallback is non-null, it will contain true if a fallback locale (one not in the acceptLanguageList) was returned. The value on entry is ignored. ULocale will be one of the locales in availableLocales, or the ROOT ULocale if if a ROOT locale was used as a fallback (because nothing else in availableLocales matched). No ULocale array element should be null; behavior is undefined if this is the case.

Parameters:
acceptLanguageList - list of acceptable locales
availableLocales - 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 status
Returns:
one of the locales from the availableLocales list, or null if none match
Status:
Stable ICU 3.4.

acceptLanguage

public static ULocale acceptLanguage(String acceptLanguageList,
                                     boolean[] fallback)
[icu] Based on a HTTP formatted list of acceptable locales, determine an available locale for the user. NullPointerException is thrown if acceptLanguageList or availableLocales is null. If fallback is non-null, it will contain true if a fallback locale (one not in the acceptLanguageList) was returned. The value on entry is ignored. ULocale will be one of the locales in availableLocales, or the ROOT ULocale if if a ROOT locale was used as a fallback (because nothing else in availableLocales matched). No ULocale array element should be null; behavior is undefined if this is the case. This function will choose a locale from the ULocale.getAvailableLocales() list as available.

Parameters:
acceptLanguageList - list in HTTP "Accept-Language:" format of acceptable locales
fallback - if non-null, a 1-element array containing a boolean to be set with the fallback status
Returns:
one of the locales from the ULocale.getAvailableLocales() list, or null if none match
Status:
Stable ICU 3.4.

acceptLanguage

public static ULocale acceptLanguage(ULocale[] acceptLanguageList,
                                     boolean[] fallback)
[icu] Based on an ordered array of acceptable locales, determine an available locale for the user. NullPointerException is thrown if acceptLanguageList or availableLocales is null. If fallback is non-null, it will contain true if a fallback locale (one not in the acceptLanguageList) was returned. The value on entry is ignored. ULocale will be one of the locales in availableLocales, or the ROOT ULocale if if a ROOT locale was used as a fallback (because nothing else in availableLocales matched). No ULocale array element should be null; behavior is undefined if this is the case. This function will choose a locale from the ULocale.getAvailableLocales() list as available.

Parameters:
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 status
Returns:
one of the locales from the ULocale.getAvailableLocales() list, or null if none match
Status:
Stable ICU 3.4.

addLikelySubtags

public static ULocale addLikelySubtags(ULocale loc)
[icu] Adds 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. For example, "und-Zzzz" cannot be maximized, since there is no reasonable maximization. Otherwise, a new ULocale instance with the maximal form is returned. Examples: "en" maximizes to "en_Latn_US" "de" maximizes to "de_Latn_US" "sr" maximizes to "sr_Cyrl_RS" "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.) "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.)

Parameters:
loc - The ULocale to maximize
Returns:
The maximized ULocale instance.
Status:
Stable ICU 4.0.

minimizeSubtags

public static ULocale minimizeSubtags(ULocale loc)
[icu] Minimizes 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. Since the minimization algorithm relies on proper maximization, see the comments for addLikelySubtags for reasons why there might not be any data. Examples:

 "en_Latn_US" minimizes to "en"

 "de_Latn_US" minimizes to "de"

 "sr_Cyrl_RS" minimizes to "sr"

 "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the
 script, and minimizing to "zh" would imply "zh_Hans_CN".) 

Parameters:
loc - The ULocale to minimize
Returns:
The minimized ULocale instance.
Status:
Stable ICU 4.0.

getExtension

public String getExtension(char key)
[icu] Returns the extension (or private use) value associated with the specified key, or null if there is no extension associated with the key. To be well-formed, the key must be one of [0-9A-Za-z]. Keys are case-insensitive, so for example 'z' and 'Z' represent the same extension.

Parameters:
key - the extension key
Returns:
The extension, or null if this locale defines no extension for the specified key.
Throws:
IllegalArgumentException - if key is not well-formed
See Also:
PRIVATE_USE_EXTENSION, UNICODE_LOCALE_EXTENSION
Status:
Draft ICU 4.2.

getExtensionKeys

public Set<Character> getExtensionKeys()
[icu] Returns the set of extension keys associated with this locale, or the empty set if it has no extensions. The returned set is unmodifiable. The keys will all be lower-case.

Returns:
the set of extension keys, or the empty set if this locale has no extensions
Status:
Draft ICU 4.2.

getUnicodeLocaleAttributes

public Set<String> getUnicodeLocaleAttributes()
[icu] Returns the set of unicode locale attributes associated with this locale, or the empty set if it has no attributes. The returned set is unmodifiable.

Returns:
The set of attributes.
Status:
Draft ICU 4.6.

getUnicodeLocaleType

public String getUnicodeLocaleType(String key)
[icu] Returns the Unicode locale type associated with the specified Unicode locale key for this locale. Returns the empty string for keys that are defined with no type. Returns null if the key is not defined. Keys are case-insensitive. The key must be two alphanumeric characters ([0-9a-zA-Z]), or an IllegalArgumentException is thrown.

Parameters:
key - the Unicode locale key
Returns:
The Unicode locale type associated with the key, or null if the locale does not define the key.
Throws:
IllegalArgumentException - if the key is not well-formed
NullPointerException - if key is null
Status:
Draft ICU 4.4.

getUnicodeLocaleKeys

public Set<String> getUnicodeLocaleKeys()
[icu] Returns the set of Unicode locale keys defined by this locale, or the empty set if this locale has none. The returned set is immutable. Keys are all lower case.

Returns:
The set of Unicode locale keys, or the empty set if this locale has no Unicode locale keywords.
Status:
Draft ICU 4.4.

toLanguageTag

public String toLanguageTag()
[icu] Returns a well-formed IETF BCP 47 language tag representing this locale.

If this ULocale has a language, script, 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).

Script: If script is not well-formed (for example "12" or "Latin"), it will be omitted.

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:

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.

Returns:
a BCP47 language tag representing the locale
See Also:
forLanguageTag(String)
Status:
Draft ICU 4.2.

forLanguageTag

public static ULocale forLanguageTag(String languageTag)
[icu] Returns a locale for the specified IETF BCP 47 language tag string.

If the specified language tag contains any ill-formed subtags, the first such subtag and all following subtags are ignored. Compare to ULocale.Builder.setLanguageTag(java.lang.String) which throws an exception in this case.

The following conversions are performed:



Copyright (c) 2011 IBM Corporation and others.