docs: private ResourceBundle findBundle(String baseName) {
      ResourceBundle resourceBundle = null;
  
      // first try to load the resource bundle with the specified locale
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      if (null != locale) {
        try {
          resourceBundle = ResourceBundle.getBundle(baseName, locale, cl);
        } catch (Exception e) {
          log.fatal("unable to load a default bundle: "+baseName+"_"+locale);
        }
        // check that the requested main locale matches the resource bundle's,
        // since we get the system fallback locale if no match is found
        if(!resourceBundle.getLocale().equals(locale)) {
          resourceBundle = null;
        }
      }
  
      // loop through the fall back locales until a bundle is found
      if (null == resourceBundle) {
        if(null != fallback) {
          while(fallback.hasMoreElements()) {
            Locale testLocale = (Locale) fallback.nextElement();
            log.debug("looking up locale "+testLocale);
            ResourceBundle testBundle = ResourceBundle.getBundle(baseName, testLocale, cl);
            String language = testBundle.getLocale().getLanguage();
            String country = testBundle.getLocale().getCountry();
  
            if (testBundle.getLocale().equals(testLocale)) {
              resourceBundle = testBundle;
              log.debug("found bundle for locale " +baseName+"_"+ testBundle.getLocale());
              break;
            } else if (testLocale.getLanguage().equals(language)) {
              if (testLocale.getCountry().equals(country)) {
                // language and country match which is good, keep looking for variant too
                resourceBundle = testBundle;
                log.debug("potential bundle: " + baseName + "_" + testBundle.getLocale());
                continue;
              } else {
                // only accept this if there is no better previous lookup
                if (null == resourceBundle) {
                  resourceBundle = testBundle;
                  log.debug("potential bundle: " + baseName+"_"+testBundle.getLocale());
                }
                continue;
              }
            }
          }
        }
  
        // make sure the resource bundle is loaded (should not happen)
        if (null == resourceBundle) {
          resourceBundle = ResourceBundle.getBundle(baseName);
          if (null != resourceBundle) {
            log.debug("system locale bundle taken: " + baseName + "_" + resourceBundle.getLocale());
          }
        }
      }
  
      return resourceBundle;
    }