src/share/classes/sun/util/resources/LocaleData.java
Print this page
*** 44,56 ****
import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import sun.util.locale.provider.LocaleProviderAdapter;
import static sun.util.locale.provider.LocaleProviderAdapter.Type.JRE;
- import sun.util.locale.provider.LocaleDataMetaInfo;
/**
* Provides information about and access to resource bundles in the
* sun.text.resources and sun.util.resources packages or in their corresponding
* packages for CLDR.
--- 44,56 ----
import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
+ import sun.util.locale.provider.LocaleDataMetaInfo;
import sun.util.locale.provider.LocaleProviderAdapter;
import static sun.util.locale.provider.LocaleProviderAdapter.Type.JRE;
/**
* Provides information about and access to resource bundles in the
* sun.text.resources and sun.util.resources packages or in their corresponding
* packages for CLDR.
*** 92,103 ****
/**
* Gets a time zone names resource bundle, using privileges
* to allow accessing a sun.* package.
*/
! public OpenListResourceBundle getTimeZoneNames(Locale locale) {
! return (OpenListResourceBundle) getBundle(type.getUtilResourcesPackage() + ".TimeZoneNames", locale);
}
/**
* Gets a collation data resource bundle, using privileges
* to allow accessing a sun.* package.
--- 92,103 ----
/**
* Gets a time zone names resource bundle, using privileges
* to allow accessing a sun.* package.
*/
! public TimeZoneNamesBundle getTimeZoneNames(Locale locale) {
! return (TimeZoneNamesBundle) getBundle(type.getUtilResourcesPackage() + ".TimeZoneNames", locale);
}
/**
* Gets a collation data resource bundle, using privileges
* to allow accessing a sun.* package.
*** 156,170 ****
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
List<Locale> candidates = super.getCandidateLocales(baseName, locale);
/* Get the locale string list from LocaleDataMetaInfo class. */
String localeString = LocaleDataMetaInfo.getSupportedLocaleString(baseName);
! if (localeString == null || localeString.length() == 0) {
! return candidates;
! }
!
! for (Iterator<Locale> l = candidates.iterator(); l.hasNext(); ) {
Locale loc = l.next();
String lstr;
if (loc.getScript().length() > 0) {
lstr = loc.toLanguageTag().replace('-', '_');
} else {
--- 156,167 ----
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
List<Locale> candidates = super.getCandidateLocales(baseName, locale);
/* Get the locale string list from LocaleDataMetaInfo class. */
String localeString = LocaleDataMetaInfo.getSupportedLocaleString(baseName);
! if (localeString != null && localeString.length() != 0) {
! for (Iterator<Locale> l = candidates.iterator(); l.hasNext();) {
Locale loc = l.next();
String lstr;
if (loc.getScript().length() > 0) {
lstr = loc.toLanguageTag().replace('-', '_');
} else {
*** 181,190 ****
--- 178,193 ----
*/
if (lstr.length() != 0 && localeString.indexOf(" " + lstr + " ") == -1) {
l.remove();
}
}
+ }
+ // Force fallback to Locale.ENGLISH for CLDR time zone names support
+ if (locale.getLanguage() != "en"
+ && baseName.contains(CLDR) && baseName.endsWith("TimeZoneNames")) {
+ candidates.add(candidates.size() - 1, Locale.ENGLISH);
+ }
return candidates;
}
/*
* Overrides "getFallbackLocale" to return null so