for (Locale locale : Locale.getAvailableLocales()) {
System.out.println("" + locale
+ "; display: " + locale.getDisplayLanguage()
+ "; name: " + locale.getDisplayName()
+ "; lang: " + locale.getLanguage()
+ "; iso3: " + locale.getISO3Language());
}
This will find some 150 locales, where ISO3 is the three letter variant, as opposed to the older two letter getLanguage.
The display language is the bare language name, whereas the display name is embellished with the country "German (Austria)."
So
public String toISO3(String name) {
for (Locale locale : Locale.getAvailableLocales()) {
if (name.equals(locale.getDisplayLanguage()) {
return locale.getISO3Language();
}
}
throw new IllegalArgumentException("No language found: " + name);
}
For the display methods there is an optional Locale parameter, to explicitly set to Locale.ENGLISH.