Returns the list of available locale suffixes for a message resource
bundle

@param messageBundle
the resource bundle path
@param servletContext
the servlet context
@return the list of available locale suffixes for a message resource
bundle
545910
public static List<String> getAvailableLocaleSuffixes(String messageBundle, ServletContext servletContext) {

		return getAvailableLocaleSuffixes(messageBundle, MSG_RESOURCE_BUNDLE_SUFFIX, servletContext);
	}
345157
@Override
	public ResourceBundlePathsIterator getBundlePaths(String bundleId,
			ConditionalCommentCallbackHandler commentCallbackHandler, Map<String, String> variants) {
		return rsHandler.getBundlePaths(bundleId, commentCallbackHandler, variants);
	}
1000486
@Route(method = HttpMethod.GET, uri = "i18n/bundles/{file<.+>}.properties")
    public Result getBundleResource(@PathParameter("file") String file,
                                    @HttpParameter(HeaderNames.IF_NONE_MATCH) String ifNoneMatch) {

        // Extract the locale from file
        if (Strings.isNullOrEmpty(file)) {
            return notFound().as(MimeTypes.TEXT);
        }

        Locale locale = InternationalizationService.DEFAULT_LOCALE;
        if (file.contains("_")) {
            // We got a locale
            locale = Locale.forLanguageTag(file.substring(file.indexOf('_') + 1).replace("_", "-"));
        }

        // Check if we have received a etag
        String etag = service.etag(locale);
        if (ifNoneMatch != null && ifNoneMatch.equals(etag)) {
            return new Result(Status.NOT_MODIFIED);
        }

        Collection<ResourceBundle> bundles = service.bundles(locale);

        // Do we have this locale
        if (bundles.isEmpty()) {
            // No, return not found
            return notFound().as(MimeTypes.TEXT);
        } else {
            StringBuilder builder = new StringBuilder();
            for (ResourceBundle bundle : bundles) {
                for (String key : bundle.keySet()) {
                    builder.append(key).append("=").append(bundle.getString(key)).append("\n");
                }
            }
            return ok(builder.toString()).as(MimeTypes.TEXT).with(HeaderNames.ETAG, etag);
        }
    }
287907
public String importMessage(String key, Locale locale) {

        key = key.trim();
        String[] tokens = key.split("#");
        if (tokens.length != 2) {
            return null;
        }
        String className = tokens[0];
        String messageName = tokens[1];
        try {
            Method messagesGet = Class.forName(className).getMethod("get");
            I_CmsMessageBundle bundle = (I_CmsMessageBundle)(messagesGet.invoke(null));
            return bundle.getBundle(locale).key(messageName);
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            return null;
        }
    }
742521
public String[] getDetails(Locale locale) {
        if (m_details == null || m_details.length == 0) {
            return s_emptyStringArray;
        }
        String[] ret = new String[m_details.length];
        for (int i = 0; i < m_details.length; i++) {
            ret[i] = getLocalizedOrCode(m_bundleName, locale, m_code, null);
        }
        return ret;
    }
826731
public String getMessage(String key, Locale locale)
	{
		if (null == locale)
		{
			return getMessage(key);
		}
		return CollectionTools.getString(getResourceBundle(locale), key, getBehaviourOnMissingMessage().getValueOnMissingMessage(key));
	}
56575
private ResourceBundle getResourceBundleFromBundle(Object resource, String baseName, Locale locale, String versionRange)
    {
    	ResourceBundle resourceBundle = null;
        if (resource == null)
        {
            Object classAccess = this.getClassBundleService(null, baseName, versionRange, null, 0);
            if (classAccess != null)
            {
                if ((classAccess != null) && (USE_NO_RESOURCE_HACK))
                {
	                try {
						URL url = classAccess.getClass().getClassLoader().getResource(baseName);
						InputStream stream = url.openStream();
						resourceBundle = new PropertyResourceBundle(stream);
					} catch (IOException e) {
						e.printStackTrace();
					}
                }
                else
                {
                    ClassLoader loader = classAccess.getClass().getClassLoader();
                	resourceBundle = ResourceBundle.getBundle(baseName, locale, loader);
                }
            }
        }
        else
        {
        	Bundle bundle = this.findBundle(resource, bundleContext, ClassFinderActivator.getPackageName(baseName, true), versionRange);
            if (USE_NO_RESOURCE_HACK)
            {
                try {
                	// TODO - If I have to do this, then I will have to link up the resourcebundle using the locales.
                	baseName = baseName.replace('.', File.separatorChar) + ClassFinderActivator.PROPERTIES;
					URL url = bundle.getEntry(baseName);
					if (url != null)
						resourceBundle = new PropertyResourceBundle(url.openStream());
				} catch (IOException e) {
					e.printStackTrace();
				}
            }
            else
            {
            	ClassLoader loader = bundle.getClass().getClassLoader();
            	resourceBundle = ResourceBundle.getBundle(baseName, locale, loader);
            }
        }
        return resourceBundle;
    }
1138348
@Override
	public List<PathMapping> getPathMappings(JoinableResourceBundle bundle, String resourcePath,
			ResourceReaderHandler rsReader) {

		List<PathMapping> pathMappings = new ArrayList<>();
		PathMapping pathMapping = null;
		GeneratorMappingHelper helper = new GeneratorMappingHelper(resourcePath);
		String path = resolver.getResourcePath(helper.getPath());
		String[] names = path.split(RESOURCE_BUNDLE_SEPARATOR);

		for (String resourceName : names) {

			path = resourceName.replace(PACKAGE_SEPARATOR, JawrConstant.URL_SEPARATOR_CHAR);
			path = control.toBundleName(path, new Locale("", "")) + PROPERTIES_FILE_SUFFIX;
			URL rbURL = LocaleUtils.getResourceBundleURL(path, config.getContext());
			if (rbURL != null) {
				String strURL = rbURL.toString();
				// returns the path mapping only if the MessageBundle are on a
				// filesystem
				if (strURL.startsWith(JawrConstant.FILE_URL_PREFIX)) {
					String parentPath = "/WEB-INF/classes/" + PathNormalizer.getParentPath(path);
					String resourceBundleName = FileNameUtils.getBaseName(path);
					MessageBundleFileFilter filter = new MessageBundleFileFilter(resourceBundleName);
					pathMapping = new PathMapping(bundle, parentPath, filter);
					pathMappings.add(pathMapping);
				}
			}
		}
		return pathMappings;
	}
1224828
public static ResourceBundle getResourceBundle() {
		final Locale currentLocale = getCurrentLocale();
		if (Locale.ENGLISH.getLanguage().equals(currentLocale.getLanguage())) {
			// there is no translations_en.properties because translations.properties is in English
			// but if user is English, do not let getBundle fallback on server's default locale
			return ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE_NAME, ROOT_LOCALE);
		}
		// and if user is not English, use the bundle if it exists for his/her Locale
		// or the bundle for the server's default locale if it exists
		// or default (English) bundle otherwise
		return ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE_NAME, currentLocale);
	}
1083120
public Collection<CmsResource> getResourcesForLocale(Locale locale) {

        return Lists.newArrayList(m_resourcesByLocale.get(locale));
    }
1053242
public static LocalizedMessages getInstance(Locale locale)
  {
    LocalizedMessages instance = null;

    if (locale == null)
    {
      locale = Locale.getDefault();
    }

    String localeKey = locale.getLanguage();
    if (localizedMessages.containsKey(localeKey))
    {
      instance = localizedMessages.get(localeKey);
    } 
    else
    {
      synchronized (LocalizedMessages.class)
      {
        if (instance == null)
        {
          instance = new LocalizedMessages(locale);
          localizedMessages.put(localeKey, instance);
        }
      }
    }

    return instance;
  }
100973
@Override
    public Collection<ResourceBundle> bundles(Locale locale) {
        Set<ResourceBundle> bundles = new LinkedHashSet<>();
        for (I18nExtension extension : extensions) {
            if (extension.locale().equals(locale)) {
                bundles.add(extension.bundle());
            }
        }
        return bundles;
    }
761627
public String getDetails(Locale locale) {

        return Messages.get().getBundle(locale).key(m_type.getDetailKey(), m_data);
    }
419759
function extractPlaceholders(messageBundle) {
	      var messageMap = messageBundle.getMessageMap();
	      var placeholders = {};
	      Object.keys(messageMap).forEach(function (msgId) {
	          placeholders[msgId] = messageMap[msgId].placeholders;
	      });
	      return placeholders;
	  }
903396
private void addMessagesToVfsBundle(Map<String, String> messages, CmsFile vfsBundleFile) throws CmsException {

        lockTemporary(vfsBundleFile);
        CmsObject cms = m_cms;
        CmsXmlContent content = CmsXmlContentFactory.unmarshal(cms, vfsBundleFile);
        Locale locale = CmsLocaleManager.getDefaultLocale();
        if (!content.hasLocale(locale)) {
            content.addLocale(cms, locale);
        }
        Element root = content.getLocaleNode(locale);
        for (Entry<String, String> entry : messages.entrySet()) {
            Element message = root.addElement(CmsVfsBundleLoaderXml.N_MESSAGE);
            Element key = message.addElement(CmsVfsBundleLoaderXml.N_KEY);
            key.setText(entry.getKey());
            Element value = message.addElement(CmsVfsBundleLoaderXml.N_VALUE);
            value.setText(entry.getValue());
        }
        content.initDocument();
        vfsBundleFile.setContents(content.marshal());
        cms.writeFile(vfsBundleFile);
    }
877328
private ResourceBundle getBundle(Locale locale) {
        return ResourceBundle.getBundle(bundleName, locale, loader, new UTF8Control());
    }
1151781
public static String getLocalisedText(final Locale locale, final String text) {
		String message = null;
		String resourceBundleBaseName = getResourceBundleBaseName();

		if (!Util.empty(resourceBundleBaseName)) {
			Locale effectiveLocale = locale;

			if (effectiveLocale == null) {
				effectiveLocale = getEffectiveLocale();
			}

			try {
				// TODO: This is slow
				ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleBaseName, effectiveLocale);
				message = bundle.getString(text);
			} catch (MissingResourceException e) {
				// Fall back to the Configuration mechanism for the default internal messages
				if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) {
					message = ConfigurationProperties.getInternalMessage(text);
				}

				if (message == null && !MISSING_RESOURCES.contains(locale)) {
					LOG.error("Missing resource mapping for locale: " + locale + ", text: " + text);
					MISSING_RESOURCES.add(locale);
				}
			}
		} else if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) {
			// Fall back to the Configuration mechanism for the default internal messages
			message = ConfigurationProperties.getInternalMessage(text);
		}

		return message;
	}