nager / Nager.Country

Worldwide Country Informations (ISO-3166-1 Alpha2, ISO-3166-1 Alpha3, ISO 639-1)
MIT License
115 stars 22 forks source link
alpha-2-country-code c-sharp calling-codes countries country country-codes country-informations countrycodes csharp currencies currency dotnet dotnet-standard iso3166-1 iso639-1 json tld

Nager.Country

The Worldwide Country Informations are available over the nuget package or as json in the zip package. The collection contains the Informations for 250 Countries.

Example Data

{
  "commonName": "Austria",
  "officialName": "Republic of Austria",
  "nativeName": "Österreich",
  "translations": [
    {
      "languageCode": "EN",
      "name": "Austria"
    },
    {
      "languageCode": "ES",
      "name": "Austria"
    },
    {
      "languageCode": "FR",
      "name": "Autriche"
    },
    ...
  ],
  "alpha2Code": "AT",
  "alpha3Code": "AUT",
  "numericCode": 40,
  "tld": [
    ".at"
  ],
  "region": "Europe",
  "subRegion": "Western Europe",
  "borderCountries": [
    "CZ",
    "DE",
    "HU",
    "IT",
    "LI",
    "SK",
    "SI",
    "CH"
  ],
  "currencies": [
    {
      "symbol": "€",
      "singular": "euro",
      "plural": "euro",
      "isoCode": "EUR",
      "numericCode": "978",
      "name": "Euro"
    }
  ],
  "callingCodes": [
    "43"
  ]
}

nuget nuget.org download count

The package is available via NuGet

PM> install-package Nager.Country
PM> install-package Nager.Country.Translation

Examples of use

Get all countries

var countryProvider = new CountryProvider();
var countries = countryProvider.GetCountries();

Get country via CountryName

var countryProvider = new CountryProvider();
var countryInfo = countryProvider.GetCountryByName("Germany");
//countryInfo.Alpha2Code -> DE
//countryInfo.Alpha3Code -> DEU
//countryInfo.NumericCode -> 276
//countryInfo.Region -> Europe
//countryInfo.SubRegion -> WesternEurope
//countryInfo...

Get country via CountryName and consider Country Translation

Require the translation package Install-Package Nager.Country.Translation

var countryProvider = new CountryProvider();
var countryInfo = countryProvider.GetCountryByNameConsiderTranslation("Germania"); // <- Germany
//countryInfo.Alpha2Code -> DE
//countryInfo.Alpha3Code -> DEU
//countryInfo.NumericCode -> 276
//countryInfo.Region -> Europe
//countryInfo.SubRegion -> WesternEurope
//countryInfo...

Get the name of the country in the requested language (nuget -> Nager.Country.Translation)

var translationProvider = new TranslationProvider();
var translatedCountryName = translationProvider.GetCountryTranslatedName(Alpha2Code.DE, LanguageCode.EN);
//translatedCountryName -> Germany

Get all Languages (nuget -> Nager.Country.Translation)

var translationProvider = new TranslationProvider();
var languages = translationProvider.GetLanguages();

Interesting projects

Language Project
* mledoze countries
* umpirsky country-list
* dr5hn countries-states-cities-database
javascript michaelwittig node-i18n-iso-countries
.net anghelvalentin CountryValidator