Java國際化(i18n) Locale類詳細示例
在這個例子中,將獲得默認的語言環境並打印其詳細信息。 然後爲「fr」
創建一個語言環境並打印其詳細信息。
文件:I18NTester.java -
import java.util.Locale;
public class I18NTester {
public static void main(String[] args) {
Locale locale =Locale.getDefault();
System.out.println("Default Locale Properties:\n");
System.out.println(locale.getDisplayCountry());
System.out.println(locale.getDisplayLanguage());
System.out.println(locale.getDisplayName());
System.out.println(locale.getISO3Country());
System.out.println(locale.getISO3Language());
System.out.println(locale.getLanguage());
System.out.println(locale.getCountry());
Locale frenchLocale = new Locale("fr","fr");
System.out.println("\nfr Locale Properties:\n");
System.out.println(frenchLocale.getDisplayCountry());
System.out.println(frenchLocale.getDisplayLanguage());
System.out.println(frenchLocale.getDisplayName());
System.out.println(frenchLocale.getISO3Country());
System.out.println(frenchLocale.getISO3Language());
System.out.println(frenchLocale.getLanguage());
System.out.println(frenchLocale.getCountry());
}
}
執行上面示例代碼,得到以下結果 -
Default Locale Properties:
中國
中文
中文 (中國)
CHN
zho
zh
CN
fr Locale Properties:
法國
法文
法文 (法國)
FRA
fra
fr
FR
0 條評論,你可以發表評論,我們會進行改進
