问题
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