private static List<CmsMessages> collectModuleMessages(Locale locale) {

        // create a new list and add the base bundle
        ArrayList<CmsMessages> result = new ArrayList<CmsMessages>();

        //////////// iterate over all registered modules ////////////////
        Set<String> names = new HashSet<String>();
        Set<String> modules = OpenCms.getModuleManager().getModuleNames();
        if (modules != null) {
            names.addAll(modules);
        }
        // use service loader to get additional bundle names
        Iterator<I_CmsWorkplaceMessageBundleProvider> providers = ServiceLoader.load(
            I_CmsWorkplaceMessageBundleProvider.class).iterator();
        while (providers.hasNext()) {
            try {
                I_CmsWorkplaceMessageBundleProvider provider = providers.next();
                names.addAll(provider.getMessageBundleNames());
            } catch (Throwable t) {
                LOG.error("Error loading workplace messages bundle names from classpath.", t);
            }
        }

        // iterate all module names
        for (String baseName : names) {
            //////////// collect the workplace.properties ////////////////
            // this should result in a name like "my.module.name.workplace"
            String bundleName = baseName + PREFIX_BUNDLE_WORKPLACE;
            // try to load a bundle with the module names
            CmsMessages msg = new CmsMessages(bundleName, locale);
            // bundle was loaded, add to list of bundles
            if (msg.isInitialized()) {
                result.add(msg);
            }
            //////////// collect the messages.properties ////////////////
            // this should result in a name like "my.module.name.messages"
            bundleName = baseName + PREFIX_BUNDLE_MESSAGES;
            // try to load a bundle with the module names
            msg = new CmsMessages(bundleName, locale);
            // bundle was loaded, add to list of bundles
            if (msg.isInitialized()) {
                result.add(msg);
            }
        }

        //////////// collect additional core packages ////////////////
        I_CmsMessageBundle[] coreMsgs = A_CmsMessageBundle.getOpenCmsMessageBundles();
        for (int i = 0; i < coreMsgs.length; i++) {
            I_CmsMessageBundle bundle = coreMsgs[i];
            result.add(bundle.getBundle(locale));
        }

        /////////// collect bundles configured in module configurations ////////
        if (OpenCms.getADEManager().isInitialized()) {
            Set<String> bundleNames = OpenCms.getADEManager().getConfiguredWorkplaceBundles();
            for (String bundleName : bundleNames) {
                CmsMessages msg = new CmsMessages(bundleName, locale);
                if (msg.isInitialized()) {
                    result.add(msg);
                }
            }
        }
        return result;
    }
private static List < CmsMessages > collectModuleMessages ( Locale locale ) { ArrayList < CmsMessages > result = new ArrayList < CmsMessages > ( ) ; Set < String > names = new HashSet < String > ( ) ; Set < String > modules = OpenCms . getModuleManager ( ) . getModuleNames ( ) ; if ( modules != null ) { names . addAll ( modules ) ; } Iterator < I_CmsWorkplaceMessageBundleProvider > providers = ServiceLoader . load ( I_CmsWorkplaceMessageBundleProvider . class ) . iterator ( ) ; while ( providers . hasNext ( ) ) { try { I_CmsWorkplaceMessageBundleProvider provider = providers . next ( ) ; names . addAll ( provider . getMessageBundleNames ( ) ) ; } catch ( Throwable t ) { LOG . error ( "Error loading workplace messages bundle names from classpath." , t ) ; } } for ( String baseName : names ) { String bundleName = baseName + PREFIX_BUNDLE_WORKPLACE ; CmsMessages msg = new CmsMessages ( bundleName , locale ) ; if ( msg . isInitialized ( ) ) { result . add ( msg ) ; } bundleName = baseName + PREFIX_BUNDLE_MESSAGES ; msg = new CmsMessages ( bundleName , locale ) ; if ( msg . isInitialized ( ) ) { result . add ( msg ) ; } } I_CmsMessageBundle [ ] coreMsgs = A_CmsMessageBundle . getOpenCmsMessageBundles ( ) ; for ( int i = 0 ; i < coreMsgs . length ; i ++ ) { I_CmsMessageBundle bundle = coreMsgs [ i ] ; result . add ( bundle . getBundle ( locale ) ) ; } if ( OpenCms . getADEManager ( ) . isInitialized ( ) ) { Set < String > bundleNames = OpenCms . getADEManager ( ) . getConfiguredWorkplaceBundles ( ) ; for ( String bundleName : bundleNames ) { CmsMessages msg = new CmsMessages ( bundleName , locale ) ; if ( msg . isInitialized ( ) ) { result . add ( msg ) ; } } } return result ; }
Gathers all localization files for the workplace from the different modules.<p>

For a module named "my.module.name" the locale file must be named
"my.module.name.workplace" or "my.module.name.messages" and
be located in the classpath so that the resource loader can find it.<p>

@param locale the selected locale

@return an initialized set of module messages