Is there a Java library/api which , given an iso language code, returns the corresponding language name. For example zh-cn should return chinese, en should return english and so on.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The Java Locale class can do this:
new Locale("zh", "cn").getDisplayName();
--> Chinese (China)
You just have to parse the language/country names.
回答2:
You don't need a library; you can use java.util.Locale
for this.
Locale locale = new Locale("zh", "cn");
System.out.println(locale.getDisplayLanguage());
This will print
Chinese
回答3:
Locale API does the country code for java languages.Refer the above link