package com.oguerreiro.resilient.config;

import java.util.Locale;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;

@Configuration
public class LocaleConfig {

  @Bean
  public LocaleResolver localeResolver() {
    //SessionLocaleResolver slr = new SessionLocaleResolver();
    //slr.setDefaultLocale(new Locale("pt", "PT"));
    //return slr;
    LocaleContextHolder.setDefaultLocale(new Locale("pt", "PT"));

    AcceptHeaderLocaleResolver resolver = new AcceptHeaderLocaleResolver();
    resolver.setDefaultLocale(new Locale("pt", "PT"));
    return resolver;
  }
}
