Package org.opencms.i18n
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
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Struct representing an element of the HTTPAccept-Language
header. -
Field Summary
-
Constructor Summary
ConstructorDescriptionCmsAcceptLanguageHeaderParser
(String header, Locale defaultLocale) Parses theAccept-Language
header.CmsAcceptLanguageHeaderParser
(javax.servlet.http.HttpServletRequest req, Locale defaultLocale) Parses theAccept-Language
header from the provided request. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Creates a value string for the HTTP Accept-Language header based on the default localed.Returns the sorted list of accepted Locales.
-
Field Details
-
ACCEPT_LANGUAGE
A constant for the HTTPAccept-Language
header.- See Also:
-
DEFAULT_QUALITY
The default m_quality value for anAcceptLanguage
object.
-
-
Constructor Details
-
CmsAcceptLanguageHeaderParser
public CmsAcceptLanguageHeaderParser(javax.servlet.http.HttpServletRequest req, Locale defaultLocale) Parses theAccept-Language
header from the provided request.- Parameters:
req
- the request to parsedefaultLocale
- the default locale to use
-
CmsAcceptLanguageHeaderParser
Parses theAccept-Language
header.- Parameters:
header
- theAccept-Language
header (i.e.en, es;q=0.8, zh-TW;q=0.1
)defaultLocale
- the default locale to use
-
-
Method Details
-
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
-