|
20 | 20 | import javax.inject.Inject;
|
21 | 21 |
|
22 | 22 | import java.util.List;
|
| 23 | +import java.util.Locale; |
23 | 24 |
|
24 | 25 | import org.springframework.context.annotation.Bean;
|
25 | 26 | import org.springframework.context.annotation.Configuration;
|
|
31 | 32 | import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
32 | 33 | import org.springframework.validation.Validator;
|
33 | 34 | import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
| 35 | +import org.springframework.web.servlet.LocaleResolver; |
34 | 36 | import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
| 37 | +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
35 | 38 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
36 | 39 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
37 | 40 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
| 41 | +import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; |
| 42 | +import org.springframework.web.servlet.i18n.SessionLocaleResolver; |
38 | 43 |
|
39 | 44 | import ru.mystamps.web.support.spring.security.CustomUserDetailsArgumentResolver;
|
40 | 45 | import ru.mystamps.web.Url;
|
@@ -95,6 +100,21 @@ public Validator getValidator() {
|
95 | 100 | return factory;
|
96 | 101 | }
|
97 | 102 |
|
| 103 | + @Override |
| 104 | + public void addInterceptors(InterceptorRegistry registry) { |
| 105 | + LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor(); |
| 106 | + interceptor.setParamName("lang"); |
| 107 | + |
| 108 | + registry.addInterceptor(interceptor); |
| 109 | + } |
| 110 | + |
| 111 | + @Bean(name = "localeResolver") |
| 112 | + public LocaleResolver getLocaleResolver() { |
| 113 | + SessionLocaleResolver resolver = new SessionLocaleResolver(); |
| 114 | + resolver.setDefaultLocale(Locale.ENGLISH); |
| 115 | + return resolver; |
| 116 | + } |
| 117 | + |
98 | 118 | @Bean
|
99 | 119 | @Inject
|
100 | 120 | public DomainClassConverter<?> getDomainClassConverter(FormattingConversionService service) {
|
|
0 commit comments