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 of ConfigAwareLocaleResolver that compares the requested URL to a map of locales

Supported 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 Details

  • Constructor Details

    • UrlPatternLocaleResolver

      public UrlPatternLocaleResolver()
  • Method Details

    • init

      protected void init(org.apache.commons.configuration2.HierarchicalConfiguration<?> config)
      Description copied from class: ConfigAwareLocaleResolver
      Performs any customization needed
      Specified by:
      init in class ConfigAwareLocaleResolver
      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 class ConfigAwareLocaleResolver
      Parameters:
      siteContext - the current site context
      request - the current request
      Returns:
      a locale object or null