Internal method for adding a resource bundle to the internal cache.<p>

@param baseName the base name of the resource bundle
@param locale the locale of the resource bundle
@param bundle the resource bundle to add
965170
private void addBundle(String baseName, Locale locale, I_CmsResourceBundle bundle) {

        CmsResourceBundleLoader.addBundleToCache(baseName, locale, bundle);
    }
128710
public ResourceBundle getResourceBundle(Class<?> aClass, String bundleName, Locale locale) {
        return getResourceBundle(aClass, bundleName, (locale == null) ? null : Collections.singletonList(locale));
    }
268736
private static ResourceBundle findMatch(String basename, Locale pref) {

        ResourceBundle match = null;
        try {
            ResourceBundle bundle = CmsResourceBundleLoader.getBundle(basename, pref);
            match = bundle;
        } catch (MissingResourceException mre) {
            // ignored
        }
        return match;
    }
993847
public static void setLocale(Locale locale) {
        if (RepositoryUtils.locale == null) {
            RepositoryUtils.locale = locale;
        } else {
            if (RepositoryUtils.locale != locale) {
                RepositoryUtils.locale = locale;
                messages = null;
                installMessages = null;
            }
        }
    }
961500
protected void addBundle (HashIntMap<TileSet> idmap, HashMap<String, Integer> namemap,
        ResourceBundle bundle)
    {
        try {
            TileSetBundle tsb = BundleUtil.extractBundle(bundle);
            // initialize it and add it to the list
            tsb.init(bundle);
            addBundle(idmap, namemap, tsb);

        } catch (Exception e) {
            log.warning("Unable to load tileset bundle '" + BundleUtil.METADATA_PATH +
                        "' from resource bundle [rbundle=" + bundle + "].", e);
        }
    }
426228
public static @Nonnull JSONObject getBundle(@Nonnull String baseName, @Nonnull Locale locale) throws MissingResourceException {
        String bundleKey = baseName + ":" + locale.toString();
        JSONObject bundleJSON = bundles.get(bundleKey);

        if (bundleJSON != null) {
            return bundleJSON;
        }

        ResourceBundle bundle = getBundle(baseName, locale, Jenkins.class.getClassLoader());
        if (bundle == null) {
            // Not in Jenkins core. Check the plugins.
            Jenkins jenkins = Jenkins.getInstance(); // will never return null
            if (jenkins != null) {
                for (PluginWrapper plugin : jenkins.getPluginManager().getPlugins()) {
                    bundle = getBundle(baseName, locale, plugin.classLoader);
                    if (bundle != null) {
                        break;
                    }
                }
            }
        }
        if (bundle == null) {
            throw new MissingResourceException("Can't find bundle for base name "
                    + baseName + ", locale " + locale, baseName + "_" + locale, "");
        }

        bundleJSON = toJSONObject(bundle);
        bundles.put(bundleKey, bundleJSON);

        return bundleJSON;
    }
204491
private void addPropertyBundle(CmsResource bundleResource) {

        NameAndLocale nameAndLocale = getNameAndLocale(bundleResource);
        Locale locale = nameAndLocale.getLocale();

        String baseName = nameAndLocale.getName();
        m_bundleBaseNames.add(baseName);
        LOG.info(
            String.format(
                "Adding property VFS bundle (path=%s, name=%s, locale=%s)",
                bundleResource.getRootPath(),
                baseName,
                "" + locale));
        Locale paramLocale = locale != null ? locale : CmsLocaleManager.getDefaultLocale();
        CmsVfsBundleParameters params = new CmsVfsBundleParameters(
            nameAndLocale.getName(),
            bundleResource.getRootPath(),
            paramLocale,
            locale == null,
            CmsVfsResourceBundle.TYPE_PROPERTIES);
        CmsVfsResourceBundle bundle = new CmsVfsResourceBundle(params);
        addBundle(baseName, locale, bundle);
    }
655948
public static @Nonnull JSONObject getBundle(@Nonnull String baseName) throws MissingResourceException {
        return getBundle(baseName, Locale.getDefault());
    }
963324
public void setBundlesType(String resourceType) {
		// Set the extension for resources and bundles
		this.resourceType = resourceType;
		this.fileExtension = "." + resourceType.toLowerCase();
		this.resourceTypePreprocessorChainFactory = new BasicGlobalPreprocessorChainFactory();
		this.resourceTypePostprocessorChainFactory = new BasicGlobalPostprocessorChainFactory();
		// Create the chain factory.
		if ("js".equals(resourceType))
			this.chainFactory = new JSPostProcessorChainFactory();
		else
			this.chainFactory = new CSSPostProcessorChainFactory();
	}
863167
void setLocale(Locale locale)
   {
      m_resourceNames = LocaleData.getStringArray(locale, LocaleData.RESOURCE_NAMES);

      String name;
      m_resourceNumbers.clear();

      for (int loop = 0; loop < m_resourceNames.length; loop++)
      {
         name = m_resourceNames[loop];
         if (name != null)
         {
            m_resourceNumbers.put(name, Integer.valueOf(loop));
         }
      }
   }
984536
public static ResourceBundle getResourceBundle(String bundleName, Locale locale)
    {
        return ResourceBundle.getBundle(bundleName, locale);
    }
1160567
protected static String[] calculateBundleNames(String baseName, Locale locale) {
        int length = 1;
        boolean hasLanguage = locale.getLanguage().length() > 0;
        if (hasLanguage) {
            length++;
        }
        boolean hasCountry = locale.getCountry().length() > 0;
        if (hasCountry) {
            length++;
        }
        boolean hasVariant = locale.getVariant().length() > 0;
        if (hasVariant) {
            length++;
        }
        String[] result = new String[length];
        int index = 0;
        result[index++] = baseName;

        if (!(hasLanguage || hasCountry || hasVariant)) {
            return result;
        }

        StringBuffer buffer = new StringBuffer(baseName);
        buffer.append('_');
        buffer.append(locale.getLanguage());
        if (hasLanguage) {
            result[index++] = new String(buffer);
        }

        if (!(hasCountry || hasVariant)) {
            return result;
        }
        buffer.append('_');
        buffer.append(locale.getCountry());
        if (hasCountry) {
            result[index++] = new String(buffer);
        }

        if (!hasVariant) {
            return result;
        }
        buffer.append('_');
        buffer.append(locale.getVariant());
        result[index++] = new String(buffer);

        return result;
    }
590286
public void setLocale(Locale locale) {
		for (int i = 0; i < 5; i++) {
			components[i].setLocale(locale);
		}
	}
785677
private void initPropertyBundle() throws CmsLoaderException, CmsException, IOException {

        for (Locale l : m_locales) {
            String filePath = m_sitepath + m_basename + "_" + l.toString();
            CmsResource resource = null;
            if (m_cms.existsResource(
                filePath,
                CmsResourceFilter.requireType(
                    OpenCms.getResourceManager().getResourceType(BundleType.PROPERTY.toString())))) {
                resource = m_cms.readResource(filePath);
                SortedProperties props = new SortedProperties();
                CmsFile file = m_cms.readFile(resource);
                props.load(
                    new InputStreamReader(
                        new ByteArrayInputStream(file.getContents()),
                        CmsFileUtil.getEncoding(m_cms, file)));
                m_keyset.updateKeySet(null, props.keySet());
                m_bundleFiles.put(l, resource);
            }
        }

    }
1210270
protected void addBundle (HashIntMap<TileSet> idmap, HashMap<String, Integer> namemap,
                              TileSetBundle bundle)
    {
        IMImageProvider improv = (_imgr == null) ?
            null : new IMImageProvider(_imgr, bundle);

        // map all of the tilesets in this bundle
        for (IntMap.IntEntry<TileSet> entry : bundle.intEntrySet()) {
            Integer tsid = entry.getKey();
            TileSet tset = entry.getValue();
            tset.setImageProvider(improv);
            idmap.put(tsid.intValue(), tset);
            namemap.put(tset.getName(), tsid);
        }
    }
863362
public ResourceBundle getResourceBundle(String baseName) {
//    System.out.println(this + " " + this.locale+" ("+resourceBundles.size()+")");
    ResourceBundle bundle = (ResourceBundle) resourceBundles.get(baseName);
    if(null == bundle) {
      resourceBundles.put(baseName, bundle = findBundle(baseName));
    }
    return bundle;
  }
713641
public static boolean hasLocale(final Locale locale) {
        try {
            ResourceBundle.getBundle(Keys.LANGUAGE, locale);

            return true;
        } catch (final MissingResourceException e) {
            return false;
        }
    }