com.ibm.icu.util
public final class ULocale extends Object implements Serializable
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 {@link #VALID_LOCALE} and {@link #ACTUAL_LOCALE} intended for use in methods named getLocale(). These methods exist in several ICU classes, including {@link com.ibm.icu.util.Calendar}, {@link com.ibm.icu.util.Currency}, {@link com.ibm.icu.text.UFormat}, {@link com.ibm.icu.text.BreakIterator}, {@link com.ibm.icu.text.Collator}, {@link com.ibm.icu.text.DateFormatSymbols}, and {@link com.ibm.icu.text.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.
See Also: java.util.Locale
UNKNOWN: ICU 2.8
Nested Class Summary | |
---|---|
static class | ULocale.Type
Opaque selector enum for getLocale(). |
Field Summary | |
---|---|
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 ULocale | PRC
Useful constant for country/region. |
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 Summary | |
---|---|
ULocale(String localeID)
Construct 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)
Construct a ULocale from a localeID constructed from the three 'fields' a, b, and c. |
Method Summary | |
---|---|
static ULocale | acceptLanguage(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, ULocale[] availableLocales, boolean[] fallback)
Based on a list of acceptable locales, determine an available locale for the user.
|
static ULocale | acceptLanguage(String acceptLanguageList, 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 String | canonicalize(String localeID)
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)
Create 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 | forLocale(Locale loc)
Return a ULocale object for a {@link java.util.Locale}.
|
static ULocale[] | getAvailableLocales()
Returns a list of all installed locales. |
String | getBaseName()
Returns the (normalized) base name for this locale. |
static String | getBaseName(String localeID)
Returns the (normalized) base name for the specified locale. |
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. |
String | getDisplayCountry()
Returns this locale's country localized for display in the default locale. |
String | getDisplayCountry(ULocale displayLocale)
Returns this locale's country localized for display in the provided 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.
|
static String | getDisplayKeyword(String keyword)
Returns a keyword localized for display in the default locale. |
static String | getDisplayKeyword(String keyword, String displayLocaleID)
Returns a keyword localized for display in the specified locale. |
static String | getDisplayKeyword(String keyword, ULocale displayLocale)
Returns a keyword localized for display in the specified locale. |
String | getDisplayKeywordValue(String keyword)
Returns a keyword value localized for display in the default locale. |
String | getDisplayKeywordValue(String keyword, ULocale displayLocale)
Returns a keyword value localized for display in the specified locale. |
static String | getDisplayKeywordValue(String localeID, String keyword, String displayLocaleID)
Returns a keyword value localized for display in the specified locale.
|
static String | getDisplayKeywordValue(String localeID, String keyword, ULocale displayLocale)
Returns a keyword value localized for display in the specified locale.
|
String | getDisplayLanguage()
Returns this locale's language localized for display in the default locale. |
String | getDisplayLanguage(ULocale displayLocale)
Returns this locale's language localized for display in the provided 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 | getDisplayName()
Returns this locale name localized for display in the default locale. |
String | getDisplayName(ULocale displayLocale)
Returns this locale name localized for display in the provided 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 | getDisplayScript()
Returns this locale's script localized for display in the default locale. |
String | getDisplayScript(ULocale displayLocale)
Returns this locale's script localized for display in the provided locale. |
static String | getDisplayScript(String localeID, String displayLocaleID)
Returns a locale's script localized for display in the provided locale.
|
static String | getDisplayScript(String localeID, ULocale displayLocale)
Returns a locale's script localized for display in the provided locale. |
String | getDisplayVariant()
Returns this locale's variant localized for display in the default locale. |
String | getDisplayVariant(ULocale displayLocale)
Returns this locale's variant localized for display in the provided 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.
|
static String | getFallback(String localeID)
Returns the fallback locale for the specified locale, which might be the empty string. |
ULocale | getFallback()
Returns the fallback locale for this locale. |
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 | getKeywords()
Returns an iterator over keywords for this locale. |
static Iterator | getKeywords(String localeID)
Returns an iterator over keywords for the specified locale. |
String | getKeywordValue(String keywordName)
Returns the value for a keyword in this locale. |
static String | getKeywordValue(String localeID, String keywordName)
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 | getName()
Returns the (normalized) full name for this locale.
|
static String | getName(String localeID)
Returns the (normalized) full name for the specified locale.
|
String | getScript()
Returns the script code for this locale, which might be the empty string. |
static String | getScript(String localeID)
Returns the script code for the specified locale, which might be the empty string. |
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 void | setDefault(ULocale newLocale)
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. |
Locale | toLocale()
Convert this ULocale object to a {@link java.util.Locale}. |
String | toString()
Returns a string representation of this object. |
UNKNOWN: ICU 2.8 (retain) This API might change or be removed in a future release.
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 2.8
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
Note: The valid locale will be returned correctly in ICU 3.0 or later. In ICU 2.8, it is not returned correctly.
UNKNOWN: ICU 2.8 (retain) This API might change or be removed in a future release.
This constructor does not 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"
UNKNOWN: ICU 2.8
See Also: ULocale
UNKNOWN: ICU 3.4
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
UNKNOWN: ICU 3.0
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
UNKNOWN: ICU 3.4 This API might change or be removed in a future release.
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
UNKNOWN: ICU 3.4 This API might change or be removed in a future release.
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
UNKNOWN: ICU 3.4 This API might change or be removed in a future release.
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
UNKNOWN: ICU 3.4 This API might change or be removed in a future release.
Parameters: localeID the locale id
Returns: the canonicalized id
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
Parameters: nonCanonicalID the locale id to canonicalize
Returns: the locale created from the canonical version of the ID.
UNKNOWN: ICU 3.0
Returns: true if this Locale is equal to the specified object.
UNKNOWN: ICU 3.0
Parameters: loc a JDK locale
UNKNOWN: ICU 3.2
UNKNOWN: ICU 3.0
Returns: the base name as a String.
UNKNOWN: ICU 3.0
Parameters: localeID the locale ID as a string
Returns: the base name as a String.
UNKNOWN: ICU 3.0
See Also: ULocale
UNKNOWN: ICU 3.0
Parameters: localeID
See Also: ULocale
UNKNOWN: ICU 3.0
UNKNOWN: ICU 2.8
Returns: the localized country name.
UNKNOWN: ICU 3.0
Parameters: displayLocale the locale in which to display the name.
Returns: the localized country name.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
Parameters: keyword the keyword to be displayed.
Returns: the localized keyword name.
See Also: ULocale
UNKNOWN: ICU 3.0
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: ULocale
UNKNOWN: ICU 3.0
Parameters: keyword the keyword to be displayed. displayLocale the locale in which to display the keyword.
Returns: the localized keyword name.
See Also: ULocale
UNKNOWN: ICU 3.0
Parameters: keyword the keyword whose value is to be displayed.
Returns: the localized value name.
UNKNOWN: ICU 3.0
Parameters: keyword the keyword whose value is to be displayed. displayLocale the locale in which to display the value.
Returns: the localized value name.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
Returns: the localized language name.
UNKNOWN: ICU 3.0
Parameters: displayLocale the locale in which to display the name.
Returns: the localized language name.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
Returns: the localized locale name.
UNKNOWN: ICU 3.0
Parameters: displayLocale the locale in which to display the locale name.
Returns: the localized locale name.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
Returns: the localized script name.
UNKNOWN: ICU 3.0
Parameters: displayLocale the locale in which to display the name.
Returns: the localized script name.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
Returns: the localized variant name.
UNKNOWN: ICU 3.0
Parameters: displayLocale the locale in which to display the name.
Returns: the localized variant name.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
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.
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.2
UNKNOWN: ICU 3.2
Throws: MissingResourceException Throws MissingResourceException if the three-letter country abbreviation is not available for this locale.
UNKNOWN: ICU 3.0
Throws: MissingResourceException Throws MissingResourceException if the three-letter country abbreviation is not available for this locale.
UNKNOWN: ICU 3.0
ftp://dkuug.dk/i18n/iso-639-2.txt
Throws: MissingResourceException Throws MissingResourceException if the three-letter language abbreviation is not available for this locale.
UNKNOWN: ICU 3.0
ftp://dkuug.dk/i18n/iso-639-2.txt
Throws: MissingResourceException Throws MissingResourceException if the three-letter language abbreviation is not available for this locale.
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
Returns: iterator over keywords, or null if there are no keywords.
UNKNOWN: ICU 3.0
Returns: an iterator over the keywords in the specified locale, or null if there are no keywords.
UNKNOWN: ICU 3.0
Parameters: keywordName name of the keyword whose value is desired. Case insensitive.
Returns: the value of the keyword, or null.
UNKNOWN: ICU 3.0
Parameters: keywordName name of the keyword whose value is desired. Case insensitive.
Returns: String the value of the keyword as a string
UNKNOWN: ICU 3.0
See Also: ULocale
UNKNOWN: ICU 3.0
See Also: ULocale
UNKNOWN: ICU 3.0
Returns: String the full name of the localeID
UNKNOWN: ICU 3.0
Parameters: localeID the localeID as a string
Returns: String the full name of the localeID
UNKNOWN: ICU 3.0
See Also: ULocale
UNKNOWN: ICU 3.0
See Also: ULocale
UNKNOWN: ICU 3.0
See Also: ULocale
UNKNOWN: ICU 3.0
See Also: ULocale
UNKNOWN: ICU 3.0
UNKNOWN: ICU 3.0
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.util.PropertyPermission
UNKNOWN: ICU 3.0
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
UNKNOWN: ICU 3.2
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
UNKNOWN: ICU 3.2
Returns: a JDK locale that either exactly represents this object or is the closest approximation.
UNKNOWN: ICU 2.8
UNKNOWN: ICU 3.0