package com.example.configuration;

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;

import java.util.Locale;

@Configuration
@EnableWebMvc
public class InternationalizationConfiguration extends WebMvcConfigurerAdapter {

	@Bean
	public MessageSource messageSource() {
		ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
		messageSource.setBasename("i18n/messages");
		messageSource.setDefaultEncoding("UTF-8");
		return messageSource;
	}

	@Bean
	public LocaleResolver localeResolver() {
		CookieLocaleResolver resolver = new CookieLocaleResolver();
		resolver.setDefaultLocale(new Locale("en"));
		resolver.setCookieName("SPRING_LOCALE");
		resolver.setCookieMaxAge(4800);
		return resolver;
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
		interceptor.setParamName("setLocale");
		registry.addInterceptor(interceptor);
	}
}

@@ -468,16 +468,98 @@
 gistry;%0A
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;%0A
 import o
@@ -905,16 +905,277 @@
 pter %7B%0A%0A
+%09private static final String%5B%5D CLASSPATH_RESOURCE_LOCATIONS = %7B%22classpath:/public/%22 %7D;%0A%0A%09@Override%0A%09public void addResourceHandlers(ResourceHandlerRegistry registry) %7B%0A%09%09registry.addResourceHandler(%22/**%22).addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);%0A%09%7D%0A%0A
 %09@Bean%0A%09

add support for static files serving