fluid-country

Kotlin multiplatform country library

License

License

Categories

Categories

Data
GroupId

GroupId

io.fluidsonic.country
ArtifactId

ArtifactId

fluid-country-metadata
Last Version

Last Version

0.9.2
Release Date

Release Date

Type

Type

module
Description

Description

fluid-country
Kotlin multiplatform country library
Project URL

Project URL

https://github.com/fluidsonic/fluid-country
Source Code Management

Source Code Management

https://github.com/fluidsonic/fluid-country

Download fluid-country-metadata

Dependencies

compile (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-common jar 1.4.10

Project Modules

There are no modules declared in this project.

fluid-country

Maven Central JCenter Tests Kotlin #fluid-libraries Slack Channel

Kotlin multiplatform country library.

This is most useful in combination with fluid-i18n for retrieving internationalized information about a country.

Installation

build.gradle.kts:

dependencies {
    implementation("io.fluidsonic.country:fluid-country:0.9.3")
}

Usage

println(Country.fromCode("US")) // US

class Country

A class with information about a specific country defined by ISO 3166-1.

val country = Country.forCode("US") // throws if code is invalid (not defined by ISO 3166-1) or has an invalid format (not two latin letters)
println(country.code) // US
println(country.code(CountryCode.Format.iso3166_alpha3)) // USA
println(country.numericCode) // 840
val country = Country.forCodeOrNull("ABC123") // null if code is invalid (not defined by ISO 3166-1) or has an invalid format (not two latin letters)
println(country) // null

class CountryCode

An inline class for ISO 3166-1 alpha-2 country codes (e.g. US or DE).

val code = CountryCode.parse("US") // throws if code has invalid format (not two latin letters)
println(code.toString()) // US
println(code.isValid()) // true - 'US' is defined by ISO 3166-1
val code = CountryCode.parse("aa") // throws if code has invalid format (not two latin letters)
println(code.toString()) // AA
println(code.isValid()) // false - 'AA' is not defined by ISO 3166-1
val code = CountryCode.parseOrNull("ABC123") // null if code has invalid format (not two latin letters)
println(code) // null

License

Apache 2.0

Versions

Version
0.9.2
0.9.1
0.9.0