code: protected ResourceBundle resolveBundle (HttpServletRequest req, String bundlePath,
                                              ClassLoader loader, boolean silent)
      {
          ResourceBundle bundle = null;
  
          if (req != null) {
              Enumeration<?> locales = req.getLocales();
              while (locales.hasMoreElements()) {
                  Locale locale = (Locale)locales.nextElement();
  
                  try {
                      // java caches resource bundles, so we don't need to reinvent the wheel here.
                      // however, java also falls back from a specific bundle to a more general one
                      // if it can't find a specific bundle. that's real nice of it, but we want
                      // first to see whether or not we have exact matches on any of the preferred
                      // locales specified by the client. if we don't, then we can rely on java's
                      // fallback mechanisms
                      bundle = ResourceBundle.getBundle(bundlePath, locale, loader);
  
                      // if it's an exact match, off we go
                      if (bundle.getLocale().equals(locale)) {
                          break;
                      }
  
                  } catch (MissingResourceException mre) {
                      // no need to freak out quite yet, see if we have something for one of the
                      // other preferred locales
                  }
              }
          }
  
          // if we were unable to find an exact match for any of the user's preferred locales, take
          // their most preferred and let java perform it's fallback logic on that one
          if (bundle == null) {
              Locale locale = (req == null) ? _deflocale : req.getLocale();
              try {
                  bundle = ResourceBundle.getBundle(bundlePath, locale, loader);
              } catch (MissingResourceException mre) {
                  if (!silent) {
                      // if we were unable even to find a default bundle, we may want to log a
                      // warning
                      log.warning("Unable to resolve any message bundle", "req", getURL(req),
                                  "locale", locale, "bundlePath", bundlePath, "classLoader", loader,
                                  "siteBundlePath", _siteBundlePath, "siteLoader", _siteLoader);
                  }
              }
          }
  
          return bundle;
      }
docs: Resolves the default resource bundle based on the locale information provided in the
  supplied http request object.