This project tries to replicate the same functionality as pycountry by wrapping iso files and provide a programatic interface.
This will help having a quick source for translations of country names, and the extra information provided by:
- ISO 3166-1 (Countries)
- ISO 639-2 (Languages)
For the status of the translations, please check the iso codes repository (which is the original source of the iso files and translations).
// Gradle Kotlin
implementation("com.jimdo:jcountry:0.1.0")
JCountry jcountry = new JCountry();
CountryDB countryDB = jcountry.getCountriesDB();
// Get the countries DB hash maps <String, Country>
var dbByAlpha2 = countryDB.getCountriesMapByAlpha2();
var dbByAlpha3 = countryDB.getCountriesMapByAlpha3();
var dbByName = countryDB.getCountriesMapByName();
// Get Translations by language based locale
Optional<ResourceBundle> bundle = countryDB.getCountriesTranslations(Locale.GERMAN);
// MX -> Mexiko
var translatedCountryName = bundle.get().getString(dbByAlpha2.get("MX").getName());
// Languages DB
LanguageDB languageDB = new LanguageDBImpl(true);
var dbByAlpha2 = languageDB.getLanguagesMapByAlpha2();
// Get Translations by language based locale
Optional<ResourceBundle> bundle = languageDB.getLanguagesTranslations(Locale.GERMAN);
// Spanisch (Kastilisch)
var translatedCountryName = bundle.get().getString(dbByAlpha2.get("es").getName());