I'm generating a list of locales and printing out their local display languages (i.e. printing out ja_JP as 日本語) using java.util.Locale. I noticed that both zh_CN (chinese simplified) and zh_TW (chinese traditional) localize as 中文 rather than 简体中文 and 繁体中文. Is there a way to get these locales to include the prefix characters for simplified and traditional without hard-coding that zh_CN should be 简体中文 and zh_TW should be 繁体中文? I know I could print out language + country (i.e. 中文 (中国), but that's not quite the same.
Here's a java snippet demonstrating that they're the same:
import java.util.Locale;
public final class test {
public static void main(String[] args) {
Locale locale1 = new Locale("zh", "cn");
System.out.println( locale1.getDisplayLanguage(locale1));
System.out.println( locale1.getDisplayLanguage(Locale.TRADITIONAL_CHINESE));
System.out.println( locale1.getDisplayLanguage(Locale.SIMPLIFIED_CHINESE));
System.out.println( locale1.getDisplayCountry(locale1));
System.out.println( "");
Locale locale2 = new Locale("zh", "tw");
System.out.println( locale2.getDisplayLanguage(locale2));
System.out.println( locale2.getDisplayLanguage(Locale.TRADITIONAL_CHINESE));
System.out.println( locale2.getDisplayLanguage(Locale.SIMPLIFIED_CHINESE));
System.out.println( locale2.getDisplayCountry(locale2));
}
}
Instantiating the Locale Objects in the following way should resolve your issue:
Locale locale1 = new Locale("zh", "CN");
Locale locale2 = new Locale("zh", "TW");