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.length() == 0) {
return candidates;
}
for (Iterator< Locale > l = candidates.iterator(); l.hasNext(); ) {
Locale loc = l.next();
String lstr = null;
if (loc.getScript().length() > 0) {
lstr = loc.toLanguageTag().replace('-', '_');
} else {
lstr = loc.toString();
int idx = lstr.indexOf("_#");
if (idx >= 0) {
lstr = lstr.substring(0, idx);
}
}
/* Every locale string in the locale string list returned from
the above getSupportedLocaleString is enclosed
within two white spaces so that we could check some locale
such as "en".
*/
if (lstr.length() != 0 && localeString.indexOf(" " + lstr + " ") == -1) {
l.remove();
}
}
return candidates;
}
|