Java Code Examples for sun.util.locale.provider.LocaleProviderAdapter#isSupportedLocale()

The following examples show how to use sun.util.locale.provider.LocaleProviderAdapter#isSupportedLocale() . 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: LocaleData.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    List<Locale> candidates = super.getCandidateLocales(baseName, locale);
    // Weed out Locales which are known to have no resource bundles
    int lastDot = baseName.lastIndexOf('.');
    String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
    LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
    LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
    Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
    if (!langtags.isEmpty()) {
        for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
            if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) {
                itr.remove();
            }
        }
    }

    // Force fallback to Locale.ENGLISH for CLDR time zone names support
    if (locale.getLanguage() != "en"
            && type == CLDR && category.equals("TimeZoneNames")) {
        candidates.add(candidates.size() - 1, Locale.ENGLISH);
    }
    return candidates;
}
 
Example 2
Source File: LocaleData.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    List<Locale> candidates = super.getCandidateLocales(baseName, locale);
    // Weed out Locales which are known to have no resource bundles
    int lastDot = baseName.lastIndexOf('.');
    String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
    LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
    LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
    Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
    if (!langtags.isEmpty()) {
        for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
            if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) {
                itr.remove();
            }
        }
    }

    // Force fallback to Locale.ENGLISH for CLDR time zone names support
    if (locale.getLanguage() != "en"
            && type == CLDR && category.equals("TimeZoneNames")) {
        candidates.add(candidates.size() - 1, Locale.ENGLISH);
    }
    return candidates;
}
 
Example 3
Source File: LocaleData.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    List<Locale> candidates = super.getCandidateLocales(baseName, locale);
    // Weed out Locales which are known to have no resource bundles
    int lastDot = baseName.lastIndexOf('.');
    String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
    LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
    LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
    Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
    if (!langtags.isEmpty()) {
        for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
            if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) {
                itr.remove();
            }
        }
    }

    // Force fallback to Locale.ENGLISH for CLDR time zone names support
    if (locale.getLanguage() != "en"
            && type == CLDR && category.equals("TimeZoneNames")) {
        candidates.add(candidates.size() - 1, Locale.ENGLISH);
    }
    return candidates;
}
 
Example 4
Source File: LocaleData.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    List<Locale> candidates = super.getCandidateLocales(baseName, locale);
    // Weed out Locales which are known to have no resource bundles
    int lastDot = baseName.lastIndexOf('.');
    String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
    LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
    LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
    Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
    if (!langtags.isEmpty()) {
        for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
            if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) {
                itr.remove();
            }
        }
    }

    // Force fallback to Locale.ENGLISH for CLDR time zone names support
    if (locale.getLanguage() != "en"
            && type == CLDR && category.equals("TimeZoneNames")) {
        candidates.add(candidates.size() - 1, Locale.ENGLISH);
    }
    return candidates;
}
 
Example 5
Source File: LocaleData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    List<Locale> candidates = super.getCandidateLocales(baseName, locale);
    // Weed out Locales which are known to have no resource bundles
    int lastDot = baseName.lastIndexOf('.');
    String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
    LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
    LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
    Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
    if (!langtags.isEmpty()) {
        for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
            if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) {
                itr.remove();
            }
        }
    }

    // Force fallback to Locale.ENGLISH for CLDR time zone names support
    if (locale.getLanguage() != "en"
            && type == CLDR && category.equals("TimeZoneNames")) {
        candidates.add(candidates.size() - 1, Locale.ENGLISH);
    }
    return candidates;
}
 
Example 6
Source File: LocaleData.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    List<Locale> candidates = super.getCandidateLocales(baseName, locale);
    // Weed out Locales which are known to have no resource bundles
    int lastDot = baseName.lastIndexOf('.');
    String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
    LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
    LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
    Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
    if (!langtags.isEmpty()) {
        for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
            if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) {
                itr.remove();
            }
        }
    }

    // Force fallback to Locale.ENGLISH for CLDR time zone names support
    if (locale.getLanguage() != "en"
            && type == CLDR && category.equals("TimeZoneNames")) {
        candidates.add(candidates.size() - 1, Locale.ENGLISH);
    }
    return candidates;
}
 
Example 7
Source File: LocaleData.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    List<Locale> candidates = super.getCandidateLocales(baseName, locale);
    // Weed out Locales which are known to have no resource bundles
    int lastDot = baseName.lastIndexOf('.');
    String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
    LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
    LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
    Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
    if (!langtags.isEmpty()) {
        for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
            if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) {
                itr.remove();
            }
        }
    }

    // Force fallback to Locale.ENGLISH for CLDR time zone names support
    if (locale.getLanguage() != "en"
            && type == CLDR && category.equals("TimeZoneNames")) {
        candidates.add(candidates.size() - 1, Locale.ENGLISH);
    }
    return candidates;
}
 
Example 8
Source File: LocaleData.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    List<Locale> candidates = super.getCandidateLocales(baseName, locale);
    // Weed out Locales which are known to have no resource bundles
    int lastDot = baseName.lastIndexOf('.');
    String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
    LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
    LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
    Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
    if (!langtags.isEmpty()) {
        for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
            if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) {
                itr.remove();
            }
        }
    }

    // Force fallback to Locale.ENGLISH for CLDR time zone names support
    if (locale.getLanguage() != "en"
            && type == CLDR && category.equals("TimeZoneNames")) {
        candidates.add(candidates.size() - 1, Locale.ENGLISH);
    }
    return candidates;
}