Class ChainLocaleResolver

java.lang.Object
org.springframework.web.servlet.i18n.AbstractLocaleResolver
org.craftercms.engine.util.spring.servlet.i18n.ChainLocaleResolver
All Implemented Interfaces:
org.springframework.web.servlet.LocaleResolver

public class ChainLocaleResolver extends org.springframework.web.servlet.i18n.AbstractLocaleResolver
Implementation of LocaleResolver that uses a chain of other LocaleResolvers.

The resolvers will be executed according to the order in the configuration file, and the chain will stop when one of the resolvers returns a supported locale. If none of the resolvers in the chain returns a locale the default one will be used.

The chain of resolvers will be executed one time for every request and the locale will be stored until the response completed.

Since:
4.0.0
Author:
joseross
  • Field Details

    • ATTR_NAME_LOCALE

      public static final String ATTR_NAME_LOCALE
    • BEAN_NAME_PATTERN

      public static final String BEAN_NAME_PATTERN
      See Also:
    • CONFIG_KEY_LOCALE_RESOLVER

      public static final String CONFIG_KEY_LOCALE_RESOLVER
      See Also:
    • CONFIG_KEY_TYPE

      public static final String CONFIG_KEY_TYPE
      See Also:
    • supportedLocales

      protected List<Locale> supportedLocales
      The list of supported locales
    • resolvers

      protected List<org.springframework.web.servlet.LocaleResolver> resolvers
      The list of LocaleResolvers
  • Constructor Details

    • ChainLocaleResolver

      public ChainLocaleResolver(org.springframework.context.ApplicationContext appContext, org.apache.commons.configuration2.HierarchicalConfiguration<?> config)
  • Method Details

    • isSupported

      protected boolean isSupported(Locale locale)
    • resolveLocale

      public Locale resolveLocale(javax.servlet.http.HttpServletRequest request)
    • setLocale

      public void setLocale(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Locale locale)