Java Code Examples for sun.util.locale.provider.LocaleResources#getLocaleName()

The following examples show how to use sun.util.locale.provider.LocaleResources#getLocaleName() . 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: Locale.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private String getDisplayKeyTypeExtensionString(String key, LocaleResources lr, Locale inLocale) {
    String type = localeExtensions.getUnicodeLocaleType(key);
    String ret = getDisplayString(type, key, inLocale, DISPLAY_UEXT_TYPE);

    if (ret == null || ret.equals(type)) {
        // no localization for this type. try combining key/type separately
        String displayType = type;
        switch (key) {
        case "cu":
            displayType = lr.getCurrencyName(type.toLowerCase(Locale.ROOT));
            break;
        case "rg":
            if (type != null &&
                // UN M.49 code should not be allowed here
                type.matches("^[a-zA-Z]{2}[zZ]{4}$")) {
                    displayType = lr.getLocaleName(type.substring(0, 2).toUpperCase(Locale.ROOT));
            }
            break;
        case "tz":
            displayType = TimeZoneNameUtility.convertLDMLShortID(type)
                .map(id -> TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, inLocale))
                .orElse(type);
            break;
        }
        ret = MessageFormat.format(lr.getLocaleName("ListKeyTypePattern"),
            getDisplayString(key, null, inLocale, DISPLAY_UEXT_KEY),
            Optional.ofNullable(displayType).orElse(type));
    }

    return ret;
}