Java Code Examples for com.ibm.icu.util.ULocale#ROOT

The following examples show how to use com.ibm.icu.util.ULocale#ROOT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ICUResourceBundle.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
private static final ULocale[] createULocaleList(String baseName,
        ClassLoader root) {
    // the canned list is a subset of all the available .res files, the idea
    // is we don't export them
    // all. gotta be a better way to do this, since to add a locale you have
    // to update this list,
    // and it's embedded in our binary resources.
    ICUResourceBundle bundle = (ICUResourceBundle) UResourceBundle.instantiateBundle(baseName, ICU_RESOURCE_INDEX, root, true);

    bundle = (ICUResourceBundle)bundle.get(INSTALLED_LOCALES);
    int length = bundle.getSize();
    int i = 0;
    ULocale[] locales = new ULocale[length];
    UResourceBundleIterator iter = bundle.getIterator();
    iter.reset();
    while (iter.hasNext()) {
        String locstr = iter.next().getKey();
        if (locstr.equals("root")) {
            locales[i++] = ULocale.ROOT;
        } else {
            locales[i++] = new ULocale(locstr);
        }
    }
    bundle = null;
    return locales;
}
 
Example 2
Source File: PluralRulesLoader.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the functionally equivalent locale.
 */
public ULocale getFunctionalEquivalent(ULocale locale, boolean[] isAvailable) {
    if (isAvailable != null && isAvailable.length > 0) {
        String localeId = ULocale.canonicalize(locale.getBaseName());
        Map<String, String> idMap = getLocaleIdToRulesIdMap(PluralType.CARDINAL);
        isAvailable[0] = idMap.containsKey(localeId);
    }

    String rulesId = getRulesIdForLocale(locale, PluralType.CARDINAL);
    if (rulesId == null || rulesId.trim().length() == 0) {
        return ULocale.ROOT; // ultimate fallback
    }

    ULocale result = getRulesIdToEquivalentULocaleMap().get(
            rulesId);
    if (result == null) {
        return ULocale.ROOT; // ultimate fallback
    }

    return result;
}
 
Example 3
Source File: CollatorServiceShim.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
private static final Collator makeInstance(ULocale desiredLocale) {
    Output<ULocale> validLocale = new Output<ULocale>(ULocale.ROOT);
    CollationTailoring t =
        CollationLoader.loadTailoring(desiredLocale, validLocale);
    return new RuleBasedCollator(t, validLocale.value);
}
 
Example 4
Source File: LocaleDisplayNamesImpl.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
ULocale getLocale() {
    return ULocale.ROOT;
}
 
Example 5
Source File: CurrencyData.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
@Override
public ULocale getULocale() {
    return ULocale.ROOT;
}
 
Example 6
Source File: RuleBasedCollator.java    From fitnotifications with Apache License 2.0 3 votes vote down vote up
/**
 * <p>
 * Constructor that takes the argument rules for customization.
 * The collator will be based on the CLDR root collation, with the
 * attributes and re-ordering of the characters specified in the argument rules.
 * <p>
 * See the User Guide's section on <a href="http://userguide.icu-project.org/collation/customization">
 * Collation Customization</a> for details on the rule syntax.
 *
 * @param rules
 *            the collation rules to build the collation table from.
 * @exception ParseException
 *                and IOException thrown. ParseException thrown when argument rules have an invalid syntax.
 *                IOException thrown when an error occurred while reading internal data.
 * @stable ICU 2.8
 */
public RuleBasedCollator(String rules) throws Exception {
    if (rules == null) {
        throw new IllegalArgumentException("Collation rules can not be null");
    }
    validLocale = ULocale.ROOT;
    internalBuildTailoring(rules);
}
 
Example 7
Source File: Collator.java    From fitnotifications with Apache License 2.0 2 votes vote down vote up
/**
 * {@icu} Returns the locale that was used to create this object, or null.
 * This may may differ from the locale requested at the time of
 * this object's creation.  For example, if an object is created
 * for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
 * drawn from <tt>en</tt> (the <i>actual</i> locale), and
 * <tt>en_US</tt> may be the most specific locale that exists (the
 * <i>valid</i> locale).
 *
 * <p>Note: This method will be implemented in ICU 3.0; ICU 2.8
 * contains a partial preview implementation.  The * <i>actual</i>
 * locale is returned correctly, but the <i>valid</i> locale is
 * not, in most cases.
 *
 * <p>The base class method always returns {@link ULocale#ROOT}.
 * Subclasses should override it if appropriate.
 *
 * @param type type of information requested, either {@link
 * com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
 * com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
 * @return the information specified by <i>type</i>, or null if
 * this object was not constructed from locale data.
 * @see com.ibm.icu.util.ULocale
 * @see com.ibm.icu.util.ULocale#VALID_LOCALE
 * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
 * @draft ICU 2.8 (retain)
 * @provisional This API might change or be removed in a future release.
 */
public ULocale getLocale(ULocale.Type type) {
    return ULocale.ROOT;
}