Home | History | Annotate | Download | only in util

Lines Matching defs:locale

21 import java.util.Locale;
37 import com.ibm.icu.impl.locale.AsciiUtil;
38 import com.ibm.icu.impl.locale.BaseLocale;
39 import com.ibm.icu.impl.locale.Extension;
40 import com.ibm.icu.impl.locale.InternalLocaleBuilder;
41 import com.ibm.icu.impl.locale.KeyTypeData;
42 import com.ibm.icu.impl.locale.LanguageTag;
43 import com.ibm.icu.impl.locale.LocaleExtensions;
44 import com.ibm.icu.impl.locale.LocaleSyntaxException;
45 import com.ibm.icu.impl.locale.ParseStatus;
46 import com.ibm.icu.impl.locale.UnicodeLocaleExtension;
52 * {@icuenhanced java.util.Locale}.{@icu _usage_}
54 * A class analogous to {@link java.util.Locale} that provides additional
60 * an object. The request includes a locale (the <i>requested</i>
61 * locale), and the returned object is constructed using data for that
62 * locale. The system may lack data for the requested locale, in
63 * which case the locale fallback mechanism will be invoked until a
64 * populated locale is found (the <i>valid</i> locale). Furthermore,
65 * even when a populated locale is found (the <i>valid</i> locale),
66 * further fallback may be required to reach a locale containing the
67 * specific data required by the service (the <i>actual</i> locale).
69 * <p>ULocale performs <b>'normalization'</b> and <b>'canonicalization'</b> of locale ids.
70 * Normalization 'cleans up' ICU locale ids as follows:
86 * id appropriate to the country of the locale (for PREEURO) or EUR (for EURO).
88 * All ULocale constructors automatically normalize the locale id. To handle
104 * actual locale arrived at during the object's construction.
106 * <p>Note: The <i>actual</i> locale is returned correctly, but the <i>valid</i>
107 * locale is not, in most cases.
109 * @see java.util.Locale
131 public static final ULocale ENGLISH = new ULocale("en", Locale.ENGLISH);
137 public static final ULocale FRENCH = new ULocale("fr", Locale.FRENCH);
143 public static final ULocale GERMAN = new ULocale("de", Locale.GERMAN);
149 public static final ULocale ITALIAN = new ULocale("it", Locale.ITALIAN);
155 public static final ULocale JAPANESE = new ULocale("ja", Locale.JAPANESE);
161 public static final ULocale KOREAN = new ULocale("ko", Locale.KOREAN);
167 public static final ULocale CHINESE = new ULocale("zh", Locale.CHINESE);
176 // Equivalent JDK Locale for ULocale.SIMPLIFIED_CHINESE is different
178 // JRE 6 or older does not. JDK's Locale.SIMPLIFIED_CHINESE is actually
181 // ULocale#toLocale() implementation uses Java reflection to create a Locale
183 // constructor, the volatile field 'Locale locale' is initialized by
186 // Because we cannot hardcode corresponding JDK Locale representation below,
187 // SIMPLIFIED_CHINESE is constructed without JDK Locale argument, and
188 // #toLocale() is used for resolving the best matching JDK Locale at runtime.
209 public static final ULocale FRANCE = new ULocale("fr_FR", Locale.FRANCE);
215 public static final ULocale GERMANY = new ULocale("de_DE", Locale.GERMANY);
221 public static final ULocale ITALY = new ULocale("it_IT", Locale.ITALY);
227 public static final ULocale JAPAN = new ULocale("ja_JP", Locale.JAPAN);
233 public static final ULocale KOREA = new ULocale("ko_KR", Locale.KOREA);
257 public static final ULocale UK = new ULocale("en_GB", Locale.UK);
263 public static final ULocale US = new ULocale("en_US", Locale.US);
269 public static final ULocale CANADA = new ULocale("en_CA", Locale.CANADA);
275 public static final ULocale CANADA_FRENCH = new ULocale("fr_CA", Locale.CANADA_FRENCH);
285 // default empty locale
286 private static final Locale EMPTY_LOCALE = new Locale("", "");
288 // special keyword key for Unicode locale attributes
298 * Enum for locale categories. These locale categories are used to get/set the default locale for
304 * Category used to represent the default locale for displaying user interfaces.
309 * Category used to represent the default locale for formatting date, number and/or currency.
315 private static final SoftCache<Locale, ULocale, Void> CACHE = new SoftCache<Locale, ULocale, Void>() {
317 protected ULocale createInstance(Locale key, Void unused) {
323 * Cache the locale.
325 private transient volatile Locale locale;
333 * Cache the locale data container fields.
334 * In future, we want to use them as the primary locale identifier storage.
340 * This table lists pairs of locale ids for canonicalization. The
399 * This table lists pairs of locale ids for canonicalization.
412 private ULocale(String localeID, Locale locale) {
414 this.locale = locale;
418 * Construct a ULocale object from a {@link java.util.Locale}.
419 * @param loc a {@link java.util.Locale}
421 private ULocale(Locale loc) {
423 this.locale = loc;
427 * {@icu} Returns a ULocale object for a {@link java.util.Locale}.
429 * @param loc a {@link java.util.Locale}
432 public static ULocale forLocale(Locale loc) {
440 * {@icu} Constructs a ULocale from a RFC 3066 locale ID. The locale ID consists
455 * @param localeID string representation of the locale, e.g:
465 * compatibility with java.util.Locale.
479 * <p>Java locale strings consisting of language, country, and
487 * @param a first component of the locale id
488 * @param b second component of the locale id
489 * @param c third component of the locale id
499 * @param nonCanonicalID the locale id to canonicalize
500 * @return the locale created from the canonical version of the ID.
504 return new ULocale(canonicalize(nonCanonicalID), (Locale)null);
532 * {@icu} Converts this ULocale object to a {@link java.util.Locale}.
533 * @return a {@link java.util.Locale} that either exactly represents this object
537 public Locale toLocale() {
538 if (locale == null) {
539 locale = JDKLocaleHelper.toLocale(this);
541 return locale;
547 private static Locale defaultLocale = Locale.getDefault();
550 private static Locale[] defaultCategoryLocales = new Locale[Category.values().length];
558 // in Java 7. On JRE 7, Locale.getDefault() should reflect the
559 // property value to the Locale's default. So ICU just relies on
560 // Locale.getDefault().
571 // Make sure the current default Locale is original.
572 // If not, it means that someone updated the default Locale.
580 // when one of Locale fields is not well-formed.
601 * The default ULocale is synchronized to the default Java Locale. This method checks
602 * the current default Java Locale and returns an equivalent ULocale.
604 * <b>Note:</b> Before Java 7, the {@link java.util.Locale} was not able to represent a
605 * locale's script. Therefore, the script field in the default ULocale is always empty unless
610 * {@link java.util.Locale} using system properties - <code>user.language</code>,
613 * default Locale's script.
617 * used on Java 7, or if the current Java default Locale is changed after start up.
625 // When Java's default locale has extensions (such as ja-JP-u-ca-japanese),
626 // Locale -> ULocale mapping requires BCP47 keyword mapping data that is currently
635 Locale currentDefault = Locale.getDefault();
641 // Detected Java default Locale change.
656 * Sets the default ULocale. This also sets the default Locale.
663 * @param newLocale the new default locale
674 Locale.setDefault(defaultLocale);
699 Locale currentCategoryDefault = JDKLocaleHelper.getDefault(category);
705 // java.util.Locale.setDefault(Locale) in Java 7 updates
706 // category locale defaults. On Java 6 or older environment,
707 // ICU4J checks if the default locale has changed and update
710 // Note: When java.util.Locale.setDefault(Locale) is called
711 // with a Locale same with the previous one, Java 7 still
712 // updates category locale defaults. On Java 6 or older env,
714 // check if the default Java Locale has changed since last
717 Locale currentDefault = Locale.getDefault();
729 // No synchronization with JDK Locale, because category default
738 * This also sets the default <code>Locale</code> for the specified <code>Category</code>
743 * @param category the specified category to set the default locale
744 * @param newLocale the new default locale
750 Locale newJavaDefault = newLocale.toLocale();
758 * This is for compatibility with Locale-- in actuality, since ULocale is
782 * @return true if this Locale is equal to the specified object.
876 * {@icunote} Unlike the Locale API, this returns an array of <code>ULocale</code>,
877 * not <code>Locale</code>. Returns a list of all installed locales.
906 * Returns the language code for this locale, which will either be the empty string
917 * Returns the language code for the locale ID,
929 * Returns the script code for this locale, which might be the empty string.
939 * {@icu} Returns the script code for the specified locale, which might be the empty
950 * Returns the country/region code for this locale, which will either be the empty string
961 * {@icu} Returns the country/region code for this locale, which will either be the empty string
963 * @param localeID The locale identification string.
975 * (1) any region specified by locale tag "rg"; if none then
976 * (2) any unicode_region_tag in the locale ID; if none then
981 * @param locale
982 * The locale (includes any keywords) from which
986 * locale elements if not found any other way.
994 ULocale locale, boolean inferRegion) {
995 String region = locale.getKeywordValue("rg");
1002 region = locale.getCountry();
1004 ULocale maximized = addLikelySubtags(locale);
1011 * Returns the variant code for this locale, which might be the empty string.
1021 * {@icu} Returns the variant code for the specified locale, which might be the empty string.
1031 * {@icu} Returns the fallback locale for the specified locale, which might be the
1040 * {@icu} Returns the fallback locale for this locale. If this locale is root,
1048 return new ULocale(getFallbackString(localeID), (Locale)null);
1052 * Returns the given (canonical) locale id minus the last part before the tags.
1075 * {@icu} Returns the (normalized) base name for this locale,
1086 * {@icu} Returns the (normalized) base name for the specified locale,
1089 * @param localeID the locale ID as a string
1101 * {@icu} Returns the (normalized) full name for this locale.
1141 * {@icu} Returns the (normalized) full name for the specified locale.
1171 * {@icu} Returns an iterator over keywords for this locale. If there
1181 * {@icu} Returns an iterator over keywords for the specified locale. If there
1183 * @return an iterator over the keywords in the specified locale, or null
1192 * {@icu} Returns the value for a keyword in this locale. If the keyword is not
1203 * {@icu} Returns the value for a keyword in the specified locale. If the keyword is
1204 * not defined, returns null. The locale name does not need to be normalized.
1214 * {@icu} Returns the canonical name for the specified locale ID. This is used to
1216 * @param localeID the locale id
1253 /* See if this is an already known locale */
1278 * {@icu} Given a keyword and a value, return a new locale with an updated
1279 * keyword and value. If the keyword is null, this removes all keywords from the locale id.
1281 * localelocale id.
1284 * <p>Related: {@link #getBaseName()} returns the locale ID string with all keywords removed.
1288 * @return the updated locale
1292 return new ULocale(setKeywordValue(localeID, keyword, value), (Locale)null);
1296 * Given a locale id, a keyword, and a value, return a new locale id with an updated
1297 * keyword and value. If the keyword is null, this removes all keywords from the locale id.
1299 * locale id. Otherwise, this adds/replaces the value for this keyword in the locale id.
1302 * <p>Related: {@link #getBaseName(String)} returns the locale ID string with all keywords removed.
1304 * @param localeID the locale id to modify
1307 * @return the updated locale id
1317 * Given a locale id, a keyword, and a value, return a new locale id with an updated
1320 * @param localeID the locale id to modify
1323 * @return the updated locale id
1332 * Returns a three-letter abbreviation for this locale's language. If the locale
1338 * three-letter language abbreviation is not available for this locale.
1346 * {@icu} Returns a three-letter abbreviation for this locale's language. If the locale
1352 * three-letter language abbreviation is not available for this locale.
1360 * Returns a three-letter abbreviation for this locale's country/region. If the locale
1364 * three-letter country abbreviation is not available for this locale.
1372 * {@icu} Returns a three-letter abbreviation for this locale's country/region. If the locale
1376 * three-letter country abbreviation is not available for this locale.
1391 * {@icu} Returns whether this locale's script is written right-to-left.
1401 * @return true if the locale's script is written right-to-left
1435 * Returns this locale's language localized for display in the default <code>DISPLAY</code> locale.
1445 * Returns this locale's language localized for display in the provided locale.
1446 * @param displayLocale the locale in which to display the name.
1455 * {@icu} Returns a locale's language localized for display in the provided locale.
1457 * @param localeID the id of the locale whose language will be displayed
1458 * @param displayLocaleID the id of the locale in which to display the name.
1468 * {@icu} Returns a locale's language localized for display in the provided locale.
1470 * @param localeID the id of the locale whose language will be displayed.
1471 * @param displayLocale the locale in which to display the name.
1479 * {@icu} Returns this locale's language localized for display in the default <code>DISPLAY</code> locale.
1490 * {@icu} Returns this locale's language localized for display in the provided locale.
1492 * @param displayLocale the locale in which to display the name.
1501 * {@icu} Returns a locale's language localized for display in the provided locale.
1504 * @param localeID the id of the locale whose language will be displayed
1505 * @param displayLocaleID the id of the locale in which to display the name.
1515 * {@icu} Returns a locale's language localized for display in the provided locale.
1518 * @param localeID the id of the locale whose language will be displayed.
1519 * @param displayLocale the locale in which to display the name.
1527 private static String getDisplayLanguageInternal(ULocale locale, ULocale displayLocale,
1529 String lang = useDialect ? locale.getBaseName() : locale.getLanguage();
1534 * Returns this locale's script localized for display in the default <code>DISPLAY</code> locale.
1544 * {@icu} Returns this locale's script localized for display in the default <code>DISPLAY</code> locale.
1556 * Returns this locale's script localized for display in the provided locale.
1557 * @param displayLocale the locale in which to display the name.
1566 * {@icu} Returns this locale's script localized for display in the provided locale.
1567 * @param displayLocale the locale in which to display the name.
1578 * {@icu} Returns a locale's script localized for display in the provided locale.
1580 * @param localeID the id of the locale whose script will be displayed
1581 * @param displayLocaleID the id of the locale in which to display the name.
1589 * {@icu} Returns a locale's script localized for display in the provided locale.
1591 * @param localeID the id of the locale whose script will be displayed
1592 * @param displayLocaleID the id of the locale in which to display the name.
1603 * {@icu} Returns a locale's script localized for display in the provided locale.
1604 * @param localeID the id of the locale whose script will be displayed.
1605 * @param displayLocale the locale in which to display the name.
1613 * {@icu} Returns a locale's script localized for display in the provided locale.
1614 * @param localeID the id of the locale whose script will be displayed.
1615 * @param displayLocale the locale in which to display the name.
1626 private static String getDisplayScriptInternal(ULocale locale, ULocale displayLocale) {
1628 .scriptDisplayName(locale.getScript());
1631 private static String getDisplayScriptInContextInternal(ULocale locale, ULocale displayLocale) {
1633 .scriptDisplayNameInContext(locale.getScript());
1637 * Returns this locale's country localized for display in the default <code>DISPLAY</code> locale.
1638 * <b>Warning: </b>this is for the region part of a valid locale ID; it cannot just be the region code (like "FR").
1649 * Returns this locale's country localized for display in the provided locale.
1650 * <b>Warning: </b>this is for the region part of a valid locale ID; it cannot just be the region code (like "FR").
1652 * @param displayLocale the locale in which to display the name.
1661 * {@icu} Returns a locale's country localized for display in the provided locale.
1662 * <b>Warning: </b>this is for the region part of a valid locale ID; it cannot just be the region code (like "FR").
1665 * @param localeID the id of the locale whose country will be displayed
1666 * @param displayLocaleID the id of the locale in which to display the name.
1675 * {@icu} Returns a locale's country localized for display in the provided locale.
1676 * <b>Warning: </b>this is for the region part of a valid locale ID; it cannot just be the region code (like "FR").
1679 * @param localeID the id of the locale whose country will be displayed.
1680 * @param displayLocale the locale in which to display the name.
1689 private static String getDisplayCountryInternal(ULocale locale, ULocale displayLocale) {
1691 .regionDisplayName(locale.getCountry());
1695 * Returns this locale's variant localized for display in the default <code>DISPLAY</code> locale.
1705 * Returns this locale's variant localized for display in the provided locale.
1706 * @param displayLocale the locale in which to display the name.
1715 * {@icu} Returns a locale's variant localized for display in the provided locale.
1717 * @param localeID the id of the locale whose variant will be displayed
1718 * @param displayLocaleID the id of the locale in which to display the name.
1727 * {@icu} Returns a locale's variant localized for display in the provided locale.
1729 * @param localeID the id of the locale whose variant will be displayed.
1730 * @param displayLocale the locale in which to display the name.
1738 private static String getDisplayVariantInternal(ULocale locale, ULocale displayLocale) {
1740 .variantDisplayName(locale.getVariant());
1744 * {@icu} Returns a keyword localized for display in the default <code>DISPLAY</code> locale.
1756 * {@icu} Returns a keyword localized for display in the specified locale.
1758 * @param displayLocaleID the id of the locale in which to display the keyword.
1768 * {@icu} Returns a keyword localized for display in the specified locale.
1770 * @param displayLocale the locale in which to display the keyword.
1784 * {@icu} Returns a keyword value localized for display in the default <code>DISPLAY</code> locale.
1795 * {@icu} Returns a keyword value localized for display in the specified locale.
1797 * @param displayLocale the locale in which to display the value.
1806 * {@icu} Returns a keyword value localized for display in the specified locale.
1808 * @param localeID the id of the locale whose keyword value is to be displayed.
1810 * @param displayLocaleID the id of the locale in which to display the value.
1821 * {@icu} Returns a keyword value localized for display in the specified locale.
1823 * @param localeID the id of the locale whose keyword value is to be displayed.
1825 * @param displayLocale the id of the locale in which to display the value.
1835 private static String getDisplayKeywordValueInternal(ULocale locale, String keyword,
1838 String value = locale.getKeywordValue(keyword);
1843 * Returns this locale name localized for display in the default <code>DISPLAY</code> locale.
1844 * @return the localized locale name.
1853 * Returns this locale name localized for display in the provided locale.
1854 * @param displayLocale the locale in which to display the locale name.
1855 * @return the localized locale name.
1863 * {@icu} Returns the locale ID localized for display in the provided locale.
1865 * @param localeID the locale whose name is to be displayed.
1866 * @param displayLocaleID the id of the locale in which to display the locale name.
1867 * @return the localized locale name.
1875 * {@icu} Returns the locale ID localized for display in the provided locale.
1877 * @param localeID the locale whose name is to be displayed.
1878 * @param displayLocale the locale in which to display the locale name.
1879 * @return the localized locale name.
1886 private static String getDisplayNameInternal(ULocale locale, ULocale displayLocale) {
1887 return LocaleDisplayNames.getInstance(displayLocale).localeDisplayName(locale);
1891 * {@icu} Returns this locale name localized for display in the default <code>DISPLAY</code> locale.
1892 * If a dialect name is present in the locale data, then it is returned.
1893 * @return the localized locale name.
1902 * {@icu} Returns this locale name localized for display in the provided locale.
1903 * If a dialect name is present in the locale data, then it is returned.
1904 * @param displayLocale the locale in which to display the locale name.
1905 * @return the localized locale name.
1913 * {@icu} Returns the locale ID localized for display in the provided locale.
1914 * If a dialect name is present in the locale data, then it is returned.
1916 * @param localeID the locale whose name is to be displayed.
1917 * @param displayLocaleID the id of the locale in which to display the locale name.
1918 * @return the localized locale name.
1927 * {@icu} Returns the locale ID localized for display in the provided locale.
1928 * If a dialect name is present in the locale data, then it is returned.
1930 * @param localeID the locale whose name is to be displayed.
1931 * @param displayLocale the locale in which to display the locale name.
1932 * @return the localized locale name.
1939 private static String getDisplayNameWithDialectInternal(ULocale locale, ULocale displayLocale) {
1941 .localeDisplayName(locale);
1945 * {@icu} Returns this locale's layout orientation for characters. The possible
1948 * @return The locale's layout orientation for characters.
1957 * {@icu} Returns this locale's layout orientation for lines. The possible
1960 * @return The locale's layout orientation for lines.
1969 * {@icu} Selector for <tt>getLocale()</tt> indicating the locale of the
1971 * valid locale. If the valid locale does not contain the
1972 * specific data being requested, then the actual locale will be
1973 * above the valid locale. If the object was not constructed from
1974 * locale data, then the valid locale is <i>null</i>.
1983 * locale for which any data exists. This is always at or above
1984 * the requested locale, and at or below the actual locale. If
1985 * the requested locale does not correspond to any resource data,
1986 * then the valid locale will be above the requested locale. If
1987 * the object was not constructed from locale data, then the
1988 * actual locale is <i>null</i>.
1990 * <p>Note: The valid locale will be returned correctly in ICU
2011 * locale for the user. NullPointerException is thrown if acceptLanguageList or
2013 * fallback locale (one not in the acceptLanguageList) was returned. The value on
2015 * ROOT ULocale if if a ROOT locale was used as a fallback (because nothing else in
2043 * {@icu} Based on a list of acceptable locales, determine an available locale for the
2045 * null. If fallback is non-null, it will contain true if a fallback locale (one not
2048 * locale was used as a fallback (because nothing else in availableLocales matched).
2072 setFallback[0]=false; // first time with this locale - not a fallback.
2092 Locale loc = aLocale.toLocale();
2093 Locale parent = LocaleUtility.fallback(loc);
2107 * locale for the user. NullPointerException is thrown if acceptLanguageList or
2109 * fallback locale (one not in the acceptLanguageList) was returned. The value on
2111 * ROOT ULocale if if a ROOT locale was used as a fallback (because nothing else in
2113 * undefined if this is the case. This function will choose a locale from the
2129 * locale for the user. NullPointerException is thrown if acceptLanguageList or
2131 * fallback locale (one not in the acceptLanguageList) was returned. The value on
2133 * ROOT ULocale if if a ROOT locale was used as a fallback (because nothing else in
2135 * undefined if this is the case. This function will choose a locale from the
2411 * {@icu} Adds the likely subtags for a provided locale ID, per the algorithm
2460 * {@icu} Minimizes the subtags for a provided locale ID, per the algorithm described
2514 * {@icu} Minimizes the subtags for a provided locale ID, per the algorithm described
2881 * @param localeID The locale ID to parse.
3084 * The key for the private use locale extension ('x').
3094 * The key for Unicode locale extension ('u').
3111 * @return The extension, or null if this locale defines no
3127 * Returns the set of extension keys associated with this locale, or the
3131 * @return the set of extension keys, or the empty set if this locale has
3140 * Returns the set of unicode locale attributes associated with
3141 * this locale, or the empty set if it has no attributes. The
3152 * Returns the Unicode locale type associated with the specified Unicode locale key
3153 * for this locale. Returns the empty string for keys that are defined with no type.
3158 * @param key the Unicode locale key
3159 * @return The Unicode locale type associated with the key, or null if the
3160 * locale does not define the key.
3168 throw new IllegalArgumentException("Invalid Unicode locale key: " + key);
3174 * Returns the set of Unicode locale keys defined by this locale, or the empty set if
3175 * this locale has none. The returned set is immutable. Keys are all lower case.
3177 * @return The set of Unicode locale keys, or the empty set if this locale has
3178 * no Unicode locale keywords.
3188 * this locale.
3230 * new Locale("xx", "YY").toLanguageTag();</pre>
3236 * @return a BCP47 language tag representing the locale
3307 * Returns a locale for the specified IETF BCP 47 language tag string.
3321 * result locale (without case normalization). If it is then
3330 * loc = Locale.forLanguageTag("de-icu4j-x-URP-lvariant-Abc-Def");
3407 * @return The locale that best represents the language tag.
3422 * {@icu} Converts the specified keyword (legacy key, or BCP 47 Unicode locale
3423 * extension key) to the equivalent BCP 47 Unicode locale extension key.
3424 * For example, BCP 47 Unicode locale extension key "co" is returned for
3432 * @param keyword the input locale keyword (either legacy key
3433 * such as "collation" or BCP 47 Unicode locale extension
3435 * @return the well-formed BCP 47 Unicode locale extension key,
3436 * or null if the specified locale keyword cannot be mapped
3437 * to a well-formed BCP 47 Unicode locale extension key.
3452 * Unicode locale extension type) to the well-formed BCP 47 Unicode locale
3454 * Unicode locale extension type "phonebk" is returned for the input
3458 * satisfies the syntax of the BCP 47 Unicode locale extension type,
3465 * @param keyword the locale keyword (either legacy key such as
3466 * "collation" or BCP 47 Unicode locale extension
3468 * @param value the locale keyword value (either legacy type
3469 * such as "phonebook" or BCP 47 Unicode locale extension
3471 * @return the well-formed BCP47 Unicode locale extension type,
3472 * or null if the locale keyword value cannot be mapped to
3473 * a well-formed BCP 47 Unicode locale extension type.
3487 * {@icu} Converts the specified keyword (BCP 47 Unicode locale extension key, or
3489 * returned for the input BCP 47 Unicode locale extension key "co".
3491 * @param keyword the input locale keyword (either BCP 47 Unicode locale
3501 // Checks if the specified locale key is well-formed with the legacy locale syntax.
3517 * {@icu} Converts the specified keyword value (BCP 47 Unicode locale extension type,
3520 * locale extension type "phonebk" with the keyword "collation" (or "co").
3530 * @param keyword the locale keyword (either legacy keyword such as
3531 * "collation" or BCP 47 Unicode locale extension
3533 * @param value the locale keyword value (either BCP 47 Unicode locale
3545 // Checks if the specified locale type is well-formed with the legacy locale syntax.
3580 * <p>The following example shows how to create a <code>Locale</code> object
3612 * <code>locale</code>. Existing state is discarded.
3614 * <p>All fields of the locale must be well-formed, see {@link Locale}.
3619 * @param locale the locale
3621 * @throws IllformedLocaleException if <code>locale</code> has
3623 * @throws NullPointerException if <code>locale</code> is null.
3627 public Builder setLocale(ULocale locale) {
3629 _locbld.setLocale(locale.base(), locale.extensions());
3669 * the language must be <a href="./Locale.html#def_language">well-formed</a>
3720 * <p>The country value in the <code>Locale</code> created by the
3771 * UNICODE_LOCALE_EXTENSION} ('u') is used for the Unicode locale extension.
3772 * Setting a value for this key replaces any existing Unicode locale key/type
3799 * Sets the Unicode locale keyword type for the given key. If the type
3807 * replaces all Unicode locale keywords with those defined in the
3810 * @param key the Unicode locale key
3811 * @param type the Unicode locale type
3830 * Adds a unicode locale attribute, if not already present, otherwise
3852 * Removes a unicode locale attribute, if present, otherwise has no
3905 * @return a new Locale
3920 // legacy locale ID assume Unicode locale keywords and
3942 // Mapping Unicode locale attribute to the special keyword, attribute=xxx-yyy
4007 // special keyword used for representing Unicode locale attributes
4042 * JDK Locale Helper
4049 * New methods in Java 7 Locale class
4066 * 6 locales. When an ICU locale matches <minumum base> with
4067 * <keyword>/<value>, the ICU locale is mapped to <Java> locale.
4069 * are mapped to Java locale "ja_JP_JP". ICU locale "nn" is mapped
4070 * to Java locale "no_NO_NY".
4082 mGetScript = Locale.class.getMethod("getScript", (Class[]) null);
4083 mGetExtensionKeys = Locale.class.getMethod("getExtensionKeys", (Class[]) null);
4084 mGetExtension = Locale.class.getMethod("getExtension", char.class);
4085 mGetUnicodeLocaleKeys = Locale.class.getMethod("getUnicodeLocaleKeys", (Class[]) null);
4086 mGetUnicodeLocaleAttributes = Locale.class.getMethod("getUnicodeLocaleAttributes", (Class[]) null);
4087 mGetUnicodeLocaleType = Locale.class.getMethod("getUnicodeLocaleType", String.class);
4088 mForLanguageTag = Locale.class.getMethod("forLanguageTag", String.class);
4099 Class<?>[] classes = Locale.class.getDeclaredClasses();
4101 if (c.getName().equals("java.util.Locale$Category")) {
4109 mGetDefault = Locale.class.getDeclaredMethod("getDefault", cCategory);
4110 mSetDefault = Locale.class.getDeclaredMethod("setDefault", cCategory, Locale.class);
4144 public static ULocale toULocale(Locale loc) {
4148 public static Locale toLocale(ULocale uloc) {
4152 private static ULocale toULocale7(Locale loc) {
4168 // Found Unicode locale extension
4214 // JDK locale no_NO_NY is not interpreted as Nynorsk by ICU,
4218 // ICU locale to JDK, we do not need to map nn_NO back to no_NO_NY.
4269 // Unicode locale key
4289 private static ULocale toULocale6(Locale loc) {
4308 private static Locale toLocale7(ULocale uloc) {
4309 Locale loc = null;
4313 // to get a mapped Locale is to go through a language tag.
4314 // A Locale with script or keywords can only have variants
4324 // the variant field in JDK Locale is case sensitive.
4328 // Locale#forLanguageTag in JDK preserves character casing
4334 loc = (Locale)mForLanguageTag.invoke(null, tag);
4342 // Without script or keywords, use a Locale constructor,
4344 loc = new Locale(uloc.getLanguage(), uloc.getCountry(), uloc.getVariant());
4349 private static Locale toLocale6(ULocale uloc) {
4367 return new Locale(names[0], names[2], names[3]);
4370 public static Locale getDefault(Category category) {
4371 Locale loc = Locale.getDefault();
4384 loc = (Locale)mGetDefault.invoke(null, cat);
4397 public static void setDefault(Category category, Locale newLocale) {
4422 // Returns true if the given Locale matches the original
4423 // default locale initialized by JVM by checking user.XXX
4426 public static boolean isOriginalDefaultLocale(Locale loc) {