package com.ruoyi.framework.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import java.util.Locale;
import java.util.TimeZone;

/**
 * I18n 配置多数据源
 *
 * @author ruoyi
 */
@Configuration
public class I18nConfig
{
    // 0.2 手工切换需要
    @Bean
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        // 默认使用的语言
        slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
        return slr;
    }

//    @Primary
//    @Bean
//    LocaleResolver createLocaleResolver() {
//        CookieLocaleResolver clr = new CookieLocaleResolver();
//        clr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
//        clr.setDefaultTimeZone(TimeZone.getDefault());
//        return clr;
//    }

}
