Class CookieLocaleResolver
- java.lang.Object
-
- org.craftercms.engine.util.spring.servlet.i18n.ConfigAwareLocaleResolver
-
- org.craftercms.engine.util.spring.servlet.i18n.CookieLocaleResolver
-
- All Implemented Interfaces:
org.springframework.web.servlet.LocaleResolver
public class CookieLocaleResolver extends ConfigAwareLocaleResolver
Implementation ofConfigAwareLocaleResolverthat reads the locale from a cookie.Supported configuration properties:
- cookieName: The name of the cookie to read, the site name will be appended, defaults to a global configurable value
- Since:
- 4.0.0
- Author:
- joseross
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_KEY_COOKIE_NAMEprotected StringcookieNameThe name of the cookieprotected StringdefaultCookieNameThe default name of the cookie, provided for backward compatibility-
Fields inherited from class org.craftercms.engine.util.spring.servlet.i18n.ConfigAwareLocaleResolver
logger
-
-
Constructor Summary
Constructors Constructor Description CookieLocaleResolver(String defaultCookieName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidinit(org.apache.commons.configuration2.HierarchicalConfiguration<?> config)Performs any customization neededprotected LocaleresolveLocale(SiteContext siteContext, javax.servlet.http.HttpServletRequest request)Performs the actual work to resolve a locale-
Methods inherited from class org.craftercms.engine.util.spring.servlet.i18n.ConfigAwareLocaleResolver
isSupported, resolveLocale, setLocale, setSupportedLocales
-
-
-
-
Field Detail
-
CONFIG_KEY_COOKIE_NAME
public static final String CONFIG_KEY_COOKIE_NAME
- See Also:
- Constant Field Values
-
cookieName
protected String cookieName
The name of the cookie
-
defaultCookieName
protected String defaultCookieName
The default name of the cookie, provided for backward compatibility
-
-
Constructor Detail
-
CookieLocaleResolver
@ConstructorProperties("defaultCookieName") public CookieLocaleResolver(String defaultCookieName)
-
-
Method Detail
-
init
protected void init(org.apache.commons.configuration2.HierarchicalConfiguration<?> config)
Description copied from class:ConfigAwareLocaleResolverPerforms any customization needed- Specified by:
initin classConfigAwareLocaleResolver- Parameters:
config- the configuration
-
resolveLocale
protected Locale resolveLocale(SiteContext siteContext, javax.servlet.http.HttpServletRequest request)
Description copied from class:ConfigAwareLocaleResolverPerforms the actual work to resolve a locale- Specified by:
resolveLocalein classConfigAwareLocaleResolver- Parameters:
siteContext- the current site contextrequest- the current request- Returns:
- a locale object or null
-
-