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

The following examples show how to use com.ibm.icu.util.ULocale#AvailableType . 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 trekarta with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void put(UResource.Key key, UResource.Value value, boolean noFallback) {
    UResource.Table resIndexTable = value.getTable();
    for (int i = 0; resIndexTable.getKeyAndValue(i, key, value); ++i) {
        ULocale.AvailableType type;
        if (key.contentEquals("InstalledLocales")) {
            type = ULocale.AvailableType.DEFAULT;
        } else if (key.contentEquals("AliasLocales")) {
            type = ULocale.AvailableType.ONLY_LEGACY_ALIASES;
        } else {
            // CLDRVersion, etc.
            continue;
        }
        UResource.Table availableLocalesTable = value.getTable();
        ULocale[] locales = new ULocale[availableLocalesTable.getSize()];
        for (int j = 0; availableLocalesTable.getKeyAndValue(j, key, value); ++j) {
            locales[j] = new ULocale(key.toString());
        }
        output.put(type, locales);
    }
}
 
Example 2
Source File: ICUResourceBundle.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
private static final EnumMap<ULocale.AvailableType, 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 rb = (ICUResourceBundle) UResourceBundle.instantiateBundle(baseName, ICU_RESOURCE_INDEX, root, true);

    EnumMap<ULocale.AvailableType, ULocale[]> result = new EnumMap<>(ULocale.AvailableType.class);
    AvailableLocalesSink sink = new AvailableLocalesSink(result);
    rb.getAllItemsWithFallback("", sink);
    return result;
}
 
Example 3
Source File: ICUResourceBundle.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
ULocale[] getULocaleList(ULocale.AvailableType type) {
    // Direct data is available for DEFAULT and ONLY_LEGACY_ALIASES
    assert type != ULocale.AvailableType.WITH_LEGACY_ALIASES;
    if (ulocales == null) {
        synchronized(this) {
            if (ulocales == null) {
                ulocales = createULocaleList(prefix, loader);
            }
        }
    }
    return ulocales.get(type);
}
 
Example 4
Source File: ICUResourceBundle.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
Locale[] getLocaleList(ULocale.AvailableType type) {
    if (locales == null) {
        getULocaleList(type);
        synchronized(this) {
            if (locales == null) {
                locales = ICUResourceBundle.getLocaleList(ulocales.get(type));
            }
        }
    }
    return locales;
}
 
Example 5
Source File: ICUResourceBundle.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Get the set of Locales installed in the specified bundles, for the specified type.
 * @return the list of available locales
 */
public static final ULocale[] getAvailableULocales(String baseName, ClassLoader loader,
        ULocale.AvailableType type) {
    return getAvailEntry(baseName, loader).getULocaleList(type);
}
 
Example 6
Source File: ICUResourceBundle.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Get the set of Locales installed in the specified bundles, for the specified type.
 * @return the list of available locales
 */
public static final Locale[] getAvailableLocales(String baseName, ClassLoader loader,
        ULocale.AvailableType type) {
    return getAvailEntry(baseName, loader).getLocaleList(type);
}
 
Example 7
Source File: ICUResourceBundle.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
public AvailableLocalesSink(EnumMap<ULocale.AvailableType, ULocale[]> output) {
    this.output = output;
}
 
Example 8
Source File: ICUResourceBundle.java    From trekarta with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the set of ULocales installed the base bundle, for the specified type.
 * @return the list of available locales for the specified type
 */
public static final ULocale[] getAvailableULocales(ULocale.AvailableType type) {
    return getAvailableULocales(ICUData.ICU_BASE_NAME, ICU_DATA_CLASS_LOADER, type);
}
 
Example 9
Source File: ICUResourceBundle.java    From trekarta with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the set of Locales installed the base bundle, for the specified type.
 * @return the list of available locales
 */
public static final Locale[] getAvailableLocales(ULocale.AvailableType type) {
    return getAvailableLocales(ICUData.ICU_BASE_NAME, ICU_DATA_CLASS_LOADER, type);
}