}
}
*/
newResourceBundle = getResourceBundle("MessagesBundle", newLocale,
new URLClassLoader(urls));
// do more searches if getBundle failed, or if the language is not the
// same and the user wanted a specific country
if ((!newResourceBundle.getLocale().getLanguage().equals(newLocale.getLanguage()) &&
!newLocale.getCountry().equals(""))) {
Locale foundLocale = newResourceBundle.getLocale();
System.out.println("changeLocale: "+
(foundLocale.toString().equals("") ? "*Default Language*" : foundLocale.getDisplayLanguage()) +
" != "+newLocale.getDisplayName()+". Searching without country..");
// try it without the country
Locale localeJustLang = new Locale(newLocale.getLanguage());
newResourceBundle = getResourceBundle("MessagesBundle", localeJustLang,
new URLClassLoader(urls));
if (newResourceBundle == null ||
!newResourceBundle.getLocale().getLanguage().equals(localeJustLang.getLanguage())) {
// find first language we have in our list
System.out.println("changeLocale: Searching for language " + newLocale.getDisplayLanguage() + " in *any* country..");
Locale[] locales = getLocales(false);
for (int i = 0; i < locales.length; i++) {
if (locales[i].getLanguage() == newLocale.getLanguage()) {
newResourceBundle = getResourceBundle("MessagesBundle", locales[i],
new URLClassLoader(urls));
break;
}
}
}
}