package com.sunzee.utils;

import android.content.res.Configuration;
import android.content.res.Resources;
import android.support.v4.app.Fragment;
import android.util.DisplayMetrics;

import com.sunzee.base.BaseApplication;

import java.util.Locale;

/**
 * 语言设置类
 */
public class LanguageUtils {
    /**
     * 给一个国际化的字符串，那么他就会自动到res中选择对应的文件，例如string_en,string_ch
     * @param lauType
     */
    public static  void set(String lauType) {
        // 本地语言设置
        Locale myLocale = new Locale(lauType);
        Resources res = BaseApplication.getContext().getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();
        conf.locale = myLocale;
        res.updateConfiguration(conf, dm);
    }
}
