Class GroovyLocaleResolver
java.lang.Object
org.craftercms.engine.util.spring.servlet.i18n.ConfigAwareLocaleResolver
org.craftercms.engine.util.spring.servlet.i18n.GroovyLocaleResolver
- All Implemented Interfaces:
org.springframework.web.servlet.LocaleResolver
Implementation of
ConfigAwareLocaleResolver that executes a Groovy script to resolve the locale
Supported configuration properties:
- script: The path of the Groovy script in the site, defaults to
/scripts/locale/resolver.groovy
- Since:
- 4.0.0
- Author:
- joseross
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected StringThe path of the Groovy scriptFields inherited from class org.craftercms.engine.util.spring.servlet.i18n.ConfigAwareLocaleResolver
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidinit(org.apache.commons.configuration2.HierarchicalConfiguration<?> config) Performs any customization neededresolveLocale(SiteContext siteContext, jakarta.servlet.http.HttpServletRequest request) Performs the actual work to resolve a localeMethods inherited from class org.craftercms.engine.util.spring.servlet.i18n.ConfigAwareLocaleResolver
isSupported, resolveLocale, setLocale, setSupportedLocales
-
Field Details
-
CONFIG_KEY_SCRIPT
- See Also:
-
DEFAULT_SCRIPT
- See Also:
-
scriptPath
The path of the Groovy script
-
-
Constructor Details
-
GroovyLocaleResolver
public GroovyLocaleResolver()
-
-
Method Details
-
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
public Locale resolveLocale(SiteContext siteContext, jakarta.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
-