Skip to content

internationalization example not working with Spring Boot 2.1.3.RELEASE #8

@thoweber

Description

@thoweber

Hi Dan,
your example MVC app on internationalization is not working with Spring Boot 2.1.3, as this version resolves the locale from the browser's accept-language header, which will always override the settings from application.properties.

I had to provide a minimal WebMvcConfigurer to allow changing the locale via a request parameter to get it to work.

`/** */
@configuration
public class WebConfig implements WebMvcConfigurer {

@Bean
public LocaleResolver localeResolver() {
	SessionLocaleResolver localeResolver = new SessionLocaleResolver();
	return localeResolver;
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
	LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
	localeChangeInterceptor.setParamName("lang");
	registry.addInterceptor(localeChangeInterceptor);
	WebMvcConfigurer.super.addInterceptors(registry);
}

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions