package com.brilliance.isc.swift.objmtconvert.util;

import com.brilliance.isc.swift.objmtconvert.annotation.model.MtCfg;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;

public class Language {

    /**
     * 无参获取国际化信息
     * @param key
     * @return
     */
    public static String getLanguage(String key,Object... objs){

        String BASE_NAME = "swift/Language/LanguageBundle";
        String language= MtCfg.LANGUAGE;
        Locale locale=Locale.getDefault();
        if("en".equals(language))
            locale=Locale.US;
        else if("zh".equals(language))
            locale=Locale.CHINESE;

        ResourceBundleControlEncode resourceBundleControlEncode=new ResourceBundleControlEncode();
        ResourceBundle usBundle = ResourceBundle.getBundle(BASE_NAME, locale,resourceBundleControlEncode);
        String bundleStr= usBundle.getString(key);
        bundleStr= MessageFormat.format(bundleStr,objs);

        return  bundleStr;
    }


    public static void main(String[] args) {
        String language= MtCfg.LANGUAGE;
        Locale locale=Locale.getDefault();
        if("US".equals(language))
            locale=Locale.US;
        else if("CHINESE".equals(language))
            locale=Locale.CHINESE;
        String BASE_NAME = "Language/LanguageBundle";

        ResourceBundleControlEncode resourceBundleControlEncode=new ResourceBundleControlEncode();

      //  System.out.println(getLanguage(BASE_NAME,locale,resourceBundleControlEncode,"n92_C1"));


    }

//    public static void main(String[] args) {
//        String language= MtCfg.LANGUAGE;
//        Locale locale=Locale.getDefault();
//        if("US".equals(language))
//            locale=Locale.US;
//        else if("CHINESE".equals(language))
//            locale=Locale.CHINESE;
//        String BASE_NAME = "Language/LanguageBundle";
//
//        ResourceBundleControlEncode resourceBundleControlEncode=new ResourceBundleControlEncode();
//
//        System.out.println(getLanguage(BASE_NAME,locale,resourceBundleControlEncode,"n92_C1"));
//
//
//    }


}
