Skip to content

ISO 3166-1 alpha-2 countries using Enumeratum and translations

License

Notifications You must be signed in to change notification settings

karadzhov/scala-iso-country

Repository files navigation

scala-iso-country Continuous integration Maven Central

scala-iso-country is a minimalistic library compatible with Scala, Scala.js and Scala Native. It simplifies the representation of ISO 3166-1 alpha-2 countries using Enumeratum and provides translations of country names into various languages.

SBT

To get started with SBT add the following to your build.sbt file:

Enum without translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-core" % "0.5.0"

Enum + Arabic translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-ar" % "0.5.0"

Enum + Bulgarian translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-bg" % "0.5.0"

Enum + Czech translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-cs" % "0.5.0"

Enum + German translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-de" % "0.5.0"

Enum + English translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-en" % "0.5.0"

Enum + Spanish translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-es" % "0.5.0"

Enum + French translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-fr" % "0.5.0"

Enum + Hindi translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-hi" % "0.5.0"

Enum + Italian translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-it" % "0.5.0"

Enum + Polish translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-pl" % "0.5.0"

Enum + Portuguese translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-pt" % "0.5.0"

Enum + Russian translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-ru" % "0.5.0"

Enum + Chinese translations

libraryDependencies += "com.karadzhov" %% "scala-iso-country-i18n-zh" % "0.5.0"

Sample

import com.karadzhov.iso.country.Country
import com.karadzhov.iso.country.i18n.CountryNameDE

Country.values
// Vector(Country.Afghanistan, Country.AlandIslands, Country.Albania...)

Country.Jamaica.entryName
// "JM"

Country.withNameOption("JM")
// Some(Country.Jamaica)

Country.withNameOption("AA")
// None

object GermanLanguagePack extends CountryNameDE

GermanLanguagePack.countryName(Country.Cambodia)
// "Kambodscha"