
Lightweight, high-performance country dataset embedding ISO 3166-1 codes, names and flag emojis; type-safe code wrappers, O(1) lookups, expressive DSL queries, tiny binary footprint.
A lightweight, high-performance Kotlin Multiplatform library providing ISO 3166-1 country data with native names and multilingual support across Android, iOS, JVM, JavaScript and WebAssembly.
dependencies {
implementation("org.kimplify:countries-core:0.1.0")
// Optional: Multilingual support
implementation("org.kimplify:countries-i18n:0.1.1")
}// Get all countries
val allCountries = Countries.repository.getAll()
// Find by code
val usa = Countries.repository.findByAlpha2(Alpha2Code("US"))
val uk = Countries.repository.findByAlpha3(Alpha3Code("GBR"))
val france = Countries.repository.findByNumeric(NumericCode("250"))
// Search by name (searches across display, native, and formal names)
val results = Countries.repository.searchByName("United")// Single filter
val usa = Countries.repository.query {
alpha2("US")
}.firstOrNull()
// Name search
val unitedCountries = Countries.repository.query {
nameContains("United")
}.toList()
// OR logic
val northAmericans = Countries.repository.query {
or {
alpha2("US")
alpha2("CA")
alpha2("MX")
}
}.toList()
// Count results
val count = Countries.repository.query {
nameStartsWith("United")
}.count()// Convert code to country
val usa = "US".toCountry()
val france = "FRA".toCountry()
val germany = "276".toCountry()
// Get properties
val flag = "US".flagEmoji // "🇺🇸"
val displayName = "US".displayCountryName // "United States"
val nativeName = "JP".nativeCountryName // "日本"
// Convert between formats
val alpha3 = "US".toAlpha3 // "USA"
val alpha2 = "USA".toAlpha2 // "US"data class Country(
val alpha2: Alpha2Code, // ISO 3166-1 alpha-2 (e.g., "US")
val alpha3: Alpha3Code, // ISO 3166-1 alpha-3 (e.g., "USA")
val numeric: NumericCode, // ISO 3166-1 numeric (e.g., "840")
val name: CountryName, // Formal ISO name (e.g., "United States of America (the)")
val flag: FlagEmoji, // Flag emoji (e.g., "🇺🇸")
val displayName: String? = null, // User-friendly name (e.g., "United States")
val native: String? = null // Native language name (e.g., "日本")
)// Extension functions for easy access
country.getDisplayName() // Returns displayName or falls back to name
country.getNativeName() // Returns native or falls back to displayName/nameAll codes are wrapped in inline value classes for type safety with zero runtime overhead:
Alpha2Code: 2-letter country codeAlpha3Code: 3-letter country codeNumericCode: 3-digit country codeCountryName: Country name stringFlagEmoji: Flag emoji stringobject Countries {
val repository: CountriesRepository // Main data access point
const val VERSION: String // Library version
const val TOTAL_COUNTRIES: Int // Total countries (249)
}interface CountriesRepository {
fun getAll(): List<Country>
fun findByAlpha2(code: Alpha2Code): Country?
fun findByAlpha3(code: Alpha3Code): Country?
fun findByNumeric(code: NumericCode): Country?
fun searchByName(query: String): List<Country>
fun query(block: CountriesQuery.() -> Unit): CountriesQueryResult
}class CountriesQuery {
fun alpha2(code: String)
fun alpha3(code: String)
fun numeric(code: String)
fun nameContains(text: String)
fun nameEquals(name: String)
fun nameStartsWith(prefix: String)
fun or(block: CountriesQuery.() -> Unit)
}
class CountriesQueryResult {
fun firstOrNull(): Country?
fun first(): Country
fun toList(): List<Country>
fun count(): Int
fun isEmpty(): Boolean
fun isNotEmpty(): Boolean
}Country data is embedded as Kotlin code for maximum performance:
Single implementation works on all platforms:
No platform-specific code needed!
Semantic versioning: MAJOR.MINOR.PATCH
Optional module providing country name translations in 6 languages.
val country = Countries.repository.findByAlpha2(Alpha2Code("JP"))!!
country.getLocalizedName(Locale.EN) // "Japan"
country.getLocalizedName(Locale.ES) // "Japón"
country.getLocalizedName(Locale.FR) // "Japon"
country.getLocalizedName(Locale.DE) // "Japan"
country.getLocalizedName(Locale.AR) // "اليابان"
country.getLocalizedName(Locale.ZH) // "日本"
country.getLocalizedName(Locale.RU) // "Япония"Supported Languages:
See countries-i18n/README.md for full documentation.
[Add your license here]
[Add contribution guidelines]
A lightweight, high-performance Kotlin Multiplatform library providing ISO 3166-1 country data with native names and multilingual support across Android, iOS, JVM, JavaScript and WebAssembly.
dependencies {
implementation("org.kimplify:countries-core:0.1.0")
// Optional: Multilingual support
implementation("org.kimplify:countries-i18n:0.1.1")
}// Get all countries
val allCountries = Countries.repository.getAll()
// Find by code
val usa = Countries.repository.findByAlpha2(Alpha2Code("US"))
val uk = Countries.repository.findByAlpha3(Alpha3Code("GBR"))
val france = Countries.repository.findByNumeric(NumericCode("250"))
// Search by name (searches across display, native, and formal names)
val results = Countries.repository.searchByName("United")// Single filter
val usa = Countries.repository.query {
alpha2("US")
}.firstOrNull()
// Name search
val unitedCountries = Countries.repository.query {
nameContains("United")
}.toList()
// OR logic
val northAmericans = Countries.repository.query {
or {
alpha2("US")
alpha2("CA")
alpha2("MX")
}
}.toList()
// Count results
val count = Countries.repository.query {
nameStartsWith("United")
}.count()// Convert code to country
val usa = "US".toCountry()
val france = "FRA".toCountry()
val germany = "276".toCountry()
// Get properties
val flag = "US".flagEmoji // "🇺🇸"
val displayName = "US".displayCountryName // "United States"
val nativeName = "JP".nativeCountryName // "日本"
// Convert between formats
val alpha3 = "US".toAlpha3 // "USA"
val alpha2 = "USA".toAlpha2 // "US"data class Country(
val alpha2: Alpha2Code, // ISO 3166-1 alpha-2 (e.g., "US")
val alpha3: Alpha3Code, // ISO 3166-1 alpha-3 (e.g., "USA")
val numeric: NumericCode, // ISO 3166-1 numeric (e.g., "840")
val name: CountryName, // Formal ISO name (e.g., "United States of America (the)")
val flag: FlagEmoji, // Flag emoji (e.g., "🇺🇸")
val displayName: String? = null, // User-friendly name (e.g., "United States")
val native: String? = null // Native language name (e.g., "日本")
)// Extension functions for easy access
country.getDisplayName() // Returns displayName or falls back to name
country.getNativeName() // Returns native or falls back to displayName/nameAll codes are wrapped in inline value classes for type safety with zero runtime overhead:
Alpha2Code: 2-letter country codeAlpha3Code: 3-letter country codeNumericCode: 3-digit country codeCountryName: Country name stringFlagEmoji: Flag emoji stringobject Countries {
val repository: CountriesRepository // Main data access point
const val VERSION: String // Library version
const val TOTAL_COUNTRIES: Int // Total countries (249)
}interface CountriesRepository {
fun getAll(): List<Country>
fun findByAlpha2(code: Alpha2Code): Country?
fun findByAlpha3(code: Alpha3Code): Country?
fun findByNumeric(code: NumericCode): Country?
fun searchByName(query: String): List<Country>
fun query(block: CountriesQuery.() -> Unit): CountriesQueryResult
}class CountriesQuery {
fun alpha2(code: String)
fun alpha3(code: String)
fun numeric(code: String)
fun nameContains(text: String)
fun nameEquals(name: String)
fun nameStartsWith(prefix: String)
fun or(block: CountriesQuery.() -> Unit)
}
class CountriesQueryResult {
fun firstOrNull(): Country?
fun first(): Country
fun toList(): List<Country>
fun count(): Int
fun isEmpty(): Boolean
fun isNotEmpty(): Boolean
}Country data is embedded as Kotlin code for maximum performance:
Single implementation works on all platforms:
No platform-specific code needed!
Semantic versioning: MAJOR.MINOR.PATCH
Optional module providing country name translations in 6 languages.
val country = Countries.repository.findByAlpha2(Alpha2Code("JP"))!!
country.getLocalizedName(Locale.EN) // "Japan"
country.getLocalizedName(Locale.ES) // "Japón"
country.getLocalizedName(Locale.FR) // "Japon"
country.getLocalizedName(Locale.DE) // "Japan"
country.getLocalizedName(Locale.AR) // "اليابان"
country.getLocalizedName(Locale.ZH) // "日本"
country.getLocalizedName(Locale.RU) // "Япония"Supported Languages:
See countries-i18n/README.md for full documentation.
[Add your license here]
[Add contribution guidelines]