Class I18nConfig

java.lang.Object
com.bytedesk.starter.config.I18nConfig
All Implemented Interfaces:
org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration public class I18nConfig extends Object implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer
国际化配置
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
    注册本地化拦截器
    org.springframework.boot.web.servlet.FilterRegistrationBean<BrowserLanguageFilter>
    创建语言过滤器Bean
    org.springframework.web.servlet.i18n.LocaleChangeInterceptor
    定义本地化拦截器,参数lang用于切换语言
    org.springframework.web.servlet.LocaleResolver
    定义本地化解析器,使用cookie存储用户语言选择
    org.springframework.context.MessageSource
    定义消息源

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer

    addArgumentResolvers, addCorsMappings, addErrorResponseInterceptors, addFormatters, addResourceHandlers, addReturnValueHandlers, addViewControllers, configureAsyncSupport, configureContentNegotiation, configureDefaultServletHandling, configureHandlerExceptionResolvers, configureMessageConverters, configurePathMatch, configureViewResolvers, extendHandlerExceptionResolvers, extendMessageConverters, getMessageCodesResolver, getValidator
  • Constructor Details

    • I18nConfig

      public I18nConfig()
  • Method Details

    • messageSource

      @Bean public org.springframework.context.MessageSource messageSource()
      定义消息源
    • localeResolver

      @Bean public org.springframework.web.servlet.LocaleResolver localeResolver()
      定义本地化解析器,使用cookie存储用户语言选择
    • localeChangeInterceptor

      @Bean public org.springframework.web.servlet.i18n.LocaleChangeInterceptor localeChangeInterceptor()
      定义本地化拦截器,参数lang用于切换语言
    • addInterceptors

      public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
      注册本地化拦截器
      Specified by:
      addInterceptors in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer
    • browserLanguageFilter

      @Bean public org.springframework.boot.web.servlet.FilterRegistrationBean<BrowserLanguageFilter> browserLanguageFilter()
      创建语言过滤器Bean