需要三个配置文件
默认都是中文,如果中英的 属性文件都没有,哪怕用的中文的locale,因为找不到文件,所以会仍然用默认的
package test;
import java.util.Locale;
import java.util.ResourceBundle;
public class TestLocale {
public static void main(String[] args) {
Locale myLocale = Locale.getDefault();
System.out.println(myLocale.getCountry());
System.out.println(myLocale.getLanguage());
System.out.println(myLocale.getDisplayCountry());
System.out.println(myLocale.getDisplayLanguage());
Locale locale1 = new Locale("zh", "CN");
ResourceBundle resb1 = ResourceBundle.getBundle("myres", locale1);
System.out.println(resb1.getString("aaa"));
Locale locale2 = new Locale("en", "US");
ResourceBundle resb2 = ResourceBundle.getBundle("myres", locale2);
System.out.println(resb2.getString("aaa"));
Locale locale3 = Locale.getDefault();
ResourceBundle resb3 = ResourceBundle.getBundle("myres", locale3);
System.out.println(resb3.getString("aaa"));
}
}