Skip to content

Commit

Permalink
Fix language settings
Browse files Browse the repository at this point in the history
  • Loading branch information
BilledTrain380 committed Dec 7, 2018
1 parent fd0d072 commit 5a37f12
Showing 1 changed file with 3 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.support.ReloadableResourceBundleMessageSource
import org.springframework.core.Ordered
import org.springframework.web.servlet.LocaleResolver
import org.springframework.web.servlet.config.annotation.*
import org.springframework.web.servlet.i18n.CookieLocaleResolver
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

/**
* Configures CORS and view controllers.
Expand All @@ -71,28 +70,6 @@ class WebConfig: WebMvcConfigurer {
registry.setOrder(Ordered.HIGHEST_PRECEDENCE)
}

override fun addResourceHandlers(registry: ResourceHandlerRegistry) {

}

override fun addInterceptors(registry: InterceptorRegistry) {

val localeInterceptor = LocaleChangeInterceptor().apply {
paramName = "lang"
}

registry.addInterceptor(localeInterceptor).addPathPatterns("/")
}

@Bean("localeResolver")
fun getLocaleResolver(): LocaleResolver {

return CookieLocaleResolver().apply {
cookieDomain = "PSA"
cookieMaxAge = 3600
}
}

@Bean("messageSource")
fun getMessageSource(): MessageSource {

Expand Down

0 comments on commit 5a37f12

Please sign in to comment.