Java library/api which converts language code to language name

扶醉桌前 提交于 2019-12-24 03:49:15

问题


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



来源:https://stackoverflow.com/questions/12910955/java-library-api-which-converts-language-code-to-language-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!