项目作者: nager

项目描述 :
Worldwide Country Informations (ISO-3166-1 Alpha2, ISO-3166-1 Alpha3, ISO 639-1)
高级语言: C#
项目地址: git://github.com/nager/Nager.Country.git
创建时间: 2019-01-26T00:15:18Z
项目社区:https://github.com/nager/Nager.Country

开源协议:MIT License

下载


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

  1. {
  2. "commonName": "Austria",
  3. "officialName": "Republic of Austria",
  4. "nativeName": "Österreich",
  5. "translations": [
  6. {
  7. "languageCode": "EN",
  8. "name": "Austria"
  9. },
  10. {
  11. "languageCode": "ES",
  12. "name": "Austria"
  13. },
  14. {
  15. "languageCode": "FR",
  16. "name": "Autriche"
  17. },
  18. ...
  19. ],
  20. "alpha2Code": "AT",
  21. "alpha3Code": "AUT",
  22. "numericCode": 40,
  23. "tld": [
  24. ".at"
  25. ],
  26. "region": "Europe",
  27. "subRegion": "Western Europe",
  28. "borderCountries": [
  29. "CZ",
  30. "DE",
  31. "HU",
  32. "IT",
  33. "LI",
  34. "SK",
  35. "SI",
  36. "CH"
  37. ],
  38. "currencies": [
  39. {
  40. "symbol": "€",
  41. "singular": "euro",
  42. "plural": "euro",
  43. "isoCode": "EUR",
  44. "numericCode": "978",
  45. "name": "Euro"
  46. }
  47. ],
  48. "callingCodes": [
  49. "43"
  50. ]
  51. }

nuget nuget.org download count

The package is available via NuGet

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

Examples of use

Get all countries

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

Get country via CountryName

  1. var countryProvider = new CountryProvider();
  2. var countryInfo = countryProvider.GetCountryByName("Germany");
  3. //countryInfo.Alpha2Code -> DE
  4. //countryInfo.Alpha3Code -> DEU
  5. //countryInfo.NumericCode -> 276
  6. //countryInfo.Region -> Europe
  7. //countryInfo.SubRegion -> WesternEurope
  8. //countryInfo...

Get country via CountryName and consider Country Translation

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

  1. var countryProvider = new CountryProvider();
  2. var countryInfo = countryProvider.GetCountryByNameConsiderTranslation("Germania"); // <- Germany
  3. //countryInfo.Alpha2Code -> DE
  4. //countryInfo.Alpha3Code -> DEU
  5. //countryInfo.NumericCode -> 276
  6. //countryInfo.Region -> Europe
  7. //countryInfo.SubRegion -> WesternEurope
  8. //countryInfo...

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

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

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

  1. var translationProvider = new TranslationProvider();
  2. 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