import java.io.UnsupportedEncodingException;
import java.util.Locale;
public final class ForeignTextDemo {
public static void main(String[] args) throws UnsupportedEncodingException {
Locale locale = new Locale("TW");
System.out.println(locale.getDisplayLanguage(Locale.TRADITIONAL_CHINESE));
locale = new Locale("CN");
System.out.println(locale.getDisplayLanguage(Locale.SIMPLIFIED_CHINESE));
}
}
When I run the program above, I get the following output:
契維文
cn
But, if I change the second locale to locale = new Locale("ZH");, I get the desired output of:
契維文
中文
Why is this? What I really want is the display language for Simplified Chinese. Is “ZH” just that?
Just “cn” isn’t the locale, the full local is “zh_CN” to differentiate with “tw_CN”.
See the list of supported locales.