(Answer based on comment by Elliott Frisch)
The Java Runtime Library doesn't have a translation API, but the Locale
class can be used to get the name of any country in any language, as long as you know the ISO 3166 alpha-2 country code, and the ISO 639 alpha-2 or alpha-3 language code.
Example for country Japan
:
Locale countryJapan = new Locale.Builder().setRegion("JP"/*Japan*/).build();
Locale langEnglish = new Locale.Builder().setLanguage("en"/*English*/).build();
Locale langPolish = new Locale.Builder().setLanguage("pl"/*Polish*/).build();
Locale langJapanese = new Locale.Builder().setLanguage("ja"/*Japanese*/).build();
Locale langItalian = new Locale.Builder().setLanguage("it"/*Italian*/).build();
System.out.println(countryJapan.getDisplayCountry(langEnglish));
System.out.println(countryJapan.getDisplayCountry(langPolish));
System.out.println(countryJapan.getDisplayCountry(langJapanese));
System.out.println(countryJapan.getDisplayCountry(langItalian));
Output
Japan
Japonia
日本
Giappone
System.out.printf("%s %s%n", Locale.JAPAN.getDisplayCountry(Locale.ENGLISH), Locale.JAPAN.getDisplayCountry(Locale.forLanguageTag("pl-PL")));