Class CmsAcceptLanguageHeaderParser

java.lang.Object
org.opencms.i18n.CmsAcceptLanguageHeaderParser

Parses the HTTP Accept-Language header as per section 14.4 of RFC 2068 (HTTP 1.1 header field definitions) and creates a sorted list of Locales from it.
Since:
6.0.0
  • Field Details

  • Constructor Details

    • CmsAcceptLanguageHeaderParser

      public CmsAcceptLanguageHeaderParser(javax.servlet.http.HttpServletRequest req, Locale defaultLocale)
      Parses the Accept-Language header from the provided request.

      Parameters:
      req - the request to parse
      defaultLocale - the default locale to use
    • CmsAcceptLanguageHeaderParser

      public CmsAcceptLanguageHeaderParser(String header, Locale defaultLocale)
      Parses the Accept-Language header.

      Parameters:
      header - the Accept-Language header (i.e. en, es;q=0.8, zh-TW;q=0.1)
      defaultLocale - the default locale to use
  • Method Details

    • createLanguageHeader

      public static String createLanguageHeader()
      Creates a value string for the HTTP Accept-Language header based on the default localed.

      Returns:
      value string for the HTTP Accept-Language
    • getAcceptedLocales

      Returns the sorted list of accepted Locales.

      Returns:
      the sorted list of accepted Locales