//current属性,由于此属性只做赋值操作,不做取值操作,因此没有get方法
private Locale current;
public void setCurrent(Locale cur) {
this.current = cur;
}
public Map<String, Locale> getLocales() throws UnsupportedEncodingException {
Map<String, Locale> locales =new HashMap<String, Locale>(3);
try {
/*这里是根据当前用户选择的语言类型,获取指定资源文件,这一步非常重要
(备注:资源文件如果不是放在src根目录下,需要加上path)*/
ResourceBundle bundle = ResourceBundle.getBundle("com/wistron/wh/swpc/homesecurity/message" , current);
if(bundle!=null){
//设置工程支持的语言类型,key里的值对应资源文件里的key的值
locales.put(bundle.getString("hs_select_zh_tw"), Locale.TAIWAN);
//locales.put(bundle.getString("hs_select_zh_cn"), Locale.CHINA);
locales.put(bundle.getString("hs_select_zh_english"), Locale.US);
}
}catch(Exception ex){
System.err.println("[Property]:Can't Load message_.properties");
ex.printStackTrace();
}
return locales;
}