Class UrlPatternLocaleResolver
- java.lang.Object
-
- org.craftercms.engine.util.spring.servlet.i18n.ConfigAwareLocaleResolver
-
- org.craftercms.engine.util.spring.servlet.i18n.UrlPatternLocaleResolver
-
- All Implemented Interfaces:
org.springframework.web.servlet.LocaleResolver
public class UrlPatternLocaleResolver extends ConfigAwareLocaleResolver
Implementation ofConfigAwareLocaleResolver
that compares the requested URL to a map of localesSupported configuration properties:
- mappings.mapping: A list of objects containing:
- pattern: A regular expression to match against the full URL of the request
- localeCode: The code of the locale to use
- Since:
- 4.0.0
- Author:
- joseross
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_KEY_LOCALE
static String
CONFIG_KEY_MAPPINGS
static String
CONFIG_KEY_PATTERN
protected Map<String,Locale>
localeMapping
The map of URL patterns and locales-
Fields inherited from class org.craftercms.engine.util.spring.servlet.i18n.ConfigAwareLocaleResolver
logger
-
-
Constructor Summary
Constructors Constructor Description UrlPatternLocaleResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
init(org.apache.commons.configuration2.HierarchicalConfiguration<?> config)
Performs any customization neededprotected Locale
resolveLocale(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_MAPPINGS
public static final String CONFIG_KEY_MAPPINGS
- See Also:
- Constant Field Values
-
CONFIG_KEY_PATTERN
public static final String CONFIG_KEY_PATTERN
- See Also:
- Constant Field Values
-
CONFIG_KEY_LOCALE
public static final String CONFIG_KEY_LOCALE
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
protected void init(org.apache.commons.configuration2.HierarchicalConfiguration<?> config)
Description copied from class:ConfigAwareLocaleResolver
Performs any customization needed- Specified by:
init
in classConfigAwareLocaleResolver
- Parameters:
config
- the configuration
-
resolveLocale
protected Locale resolveLocale(SiteContext siteContext, javax.servlet.http.HttpServletRequest request)
Description copied from class:ConfigAwareLocaleResolver
Performs the actual work to resolve a locale- Specified by:
resolveLocale
in classConfigAwareLocaleResolver
- Parameters:
siteContext
- the current site contextrequest
- the current request- Returns:
- a locale object or null
-
-