code: public static String getLocalizedMessage(CmsMessageContainer container, CmsObject cms) {
  
          Locale locale;
          if (cms != null) {
              CmsRequestContext context = cms.getRequestContext();
              locale = (context != null) ? context.getLocale() : Locale.getDefault();
          } else {
              locale = Locale.getDefault();
          }
          return container.key(locale);
      }
docs: Returns the String for the given CmsMessageContainer localized to the current user's locale
  if available or to the default locale else.
  <p>
  
  This method is needed for localization of non- {@link org.opencms.main.CmsException}
  instances that have to be thrown here due to API constraints (javax.servlet.jsp).
  <p>
  
  @param container A CmsMessageContainer containing the message to localize.
  @param cms the <code>CmsObject</code> belonging to the current user (e.g. obtained with
  <code>CmsFlexController.getCmsObject(ServletRequest)</code>).
  @return the String for the given CmsMessageContainer localized to the current user's locale
  if available or to the default locale else.
  <p>