antonioribeiro / countries

Laravel countries and currencies
BSD 3-Clause "New" or "Revised" License
1.82k stars 283 forks source link

How to retrieve a list of countries? #113

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi,

I would really appreciate any support on this.

It can't just be me that's wondering this, how do you retrieve a list of all Countries? I've tried the $countries::all() from the documentation which seems to be the perfect answer. However, 'Europe Union' and a number of other territories such as 'USNB Guantanamo Bay' and 'British Indian Ocean Territory' do not classify as countries.

Many thanks, Adam

tillkruss commented 5 years ago

Same question.

tillkruss commented 5 years ago

Ping @antonioribeiro

antonioribeiro commented 5 years ago

Data provided from this package come from some others (mledoze/countries Natural Earth Vector...), so, usually, when we miss something running the update.php script may be able to fix it.

Just updated, pushed and tagged a new version, because we have a lot of fixes, but we did not get any new countries, so I'm afraid an issue must be filled on those other repositories.

We can also create overloads, to provide missing data:

image

As for Europe Union, we have it on the overload dir, because, yes, I could not find it either when I built this package.

$countries->all()->EUR)
array:68 [
  "abbrev" => "EU"
  "abbrev_len" => "2.00"
  "adm0_a3" => "EUR"
  "adm0_a3_is" => "EUR"
  "adm0_a3_un" => "-99.00"
  "adm0_a3_us" => "EUR"
  "adm0_a3_wb" => "-99.00"
  "adm0_dif" => "1.00"
  "admin" => "Europe Union"
  "alt_spellings" => array:1 [
    0 => "EU"
  ]
  "brk_a3" => "EUR"
  "brk_diff" => "0.00"
  "brk_group" => ""
  "brk_name" => "Europe Union"
  "capital" => ""
  "cca2" => "EU"
  "cca3" => "EUR"
  "ccn3" => "250"
  "cioc" => "EUR"
  "currency" => array:1 [
    0 => "EUR"
  ]
  "demonym" => "European"
  "dialling" => []
  "economy" => "1. Developed region: G7"
  "extra" => array:2 [
    "address_format" => "{{recipient}}{{street}}{{postalcode}} {{city}}{{country}}"
    "emoji" => "🇪🇺"
  ]
  "flag" => array:7 [
    "emoji" => "🇪🇺"
    "sprite" => "<span class="flag flag-eur"></span>"
    "flag-icon" => "<span class="flag-icon flag-icon-eu"></span>"
    "flag-icon-squared" => "<span class="flag-icon flag-icon-eu flag-icon-squared"></span>"
    "world-flags-sprite" => "<span class="flag eur"></span>"
    "svg" => null
    "svg_path" => "/Users/antoniocarlos/code/pragmarx/countries/vendor/pragmarx/countries/src/data/flags/eur.svg"
  ]
  "formal_en" => "Europe Union"
  "geo" => array:20 [
    "area" => 4475757
    "pop_est" => "511805088.00"
    "pop_year" => "2017.00"
    "borders" => array:28 [
      0 => "AUT"
      1 => "BEL"
      2 => "BGR"
      3 => "HRV"
      4 => "CYP"
      5 => "CZE"
      6 => "DNK"
      7 => "EST"
      8 => "FIN"
      9 => "FRA"
      10 => "DEU"
      11 => "GRC"
      12 => "HUN"
      13 => "IRL"
      14 => "ITA"
      15 => "LVA"
      16 => "LTU"
      17 => "LUX"
      18 => "MLT"
      19 => "NLD"
      20 => "POL"
      21 => "PRT"
      22 => "ROU"
      23 => "SVK"
      24 => "SVN"
      25 => "ESP"
      26 => "SWE"
      27 => "GBR"
    ]
    "continent" => array:1 [
      "EU" => "Europe"
    ]
    "independent" => "Yes"
    "landlocked" => false
    "latitude" => "42 43 N"
    "latitude_desc" => "42.678693"
    "latlng" => array:2 [
      0 => 42
      1 => 23
    ]
    "longitude" => "23 18 E"
    "longitude_desc" => "23.321737"
    "postal_code" => false
    "region" => "Europe"
    "region_code" => "150"
    "region_un" => "Europe"
    "region_wb" => "Europe & Central Asia"
    "subregion" => "Western Europe"
    "subregion_code" => "155"
    "world_region" => "EMEA"
  ]
  "geou_dif" => "0.00"
  "geounit" => "Europe Union"
  "gu_a3" => "EUR"
  "homepart" => "1.00"
  "income_grp" => "1. High income: OECD"
  "iso_3166_1_alpha2" => "EU"
  "iso_3166_1_alpha3" => "EUR"
  "iso_3166_1_numeric" => "250"
  "iso_a2" => "EU"
  "iso_a3" => "EUR"
  "iso_a3_eh" => "EUR"
  "iso_n3" => "250"
  "labelrank" => "2.00"
  "type" => "Political and economic union"
  "scripts" => array:3 [
    0 => "Latin"
    1 => "Greek"
    2 => "Cyrillic"
  ]
  "religion" => array:7 [
    0 => "Roman Catholic"
    1 => "irreligious"
    2 => "Protestant"
    3 => "Eastern Orthodox"
    4 => "other Christian"
    5 => "Muslim"
    6 => "other faiths"
  ]
  "languages" => array:24 [
    "eng" => "English"
    "deu" => "German"
    "fra" => "French"
    "ita" => "Italian"
    "spa" => "Spanish"
    "pol" => "Polish"
    "ron" => "Romanian"
    "nld" => "Dutch"
    "ell" => "Greek"
    "hun" => "Hungarian"
    "por" => "Portuguese"
    "ces" => "Czech"
    "swe" => "Swedish"
    "bul" => "Bulgarian"
    "slk" => "Slovak"
    "dan" => "Danish"
    "fin" => "Finnish"
    "lit" => "Lithuanian"
    "hrv" => "Croatian"
    "slv" => "Slovenian"
    "est" => "Estonian"
    "gle" => "Irish"
    "lav" => "Latvian"
    "mlt" => "Maltese"
  ]
  "name" => array:3 [
    "common" => "Europe Union"
    "native" => array:1 [
      "en" => array:2 [
        "common" => "Europe Union"
        "official" => "Europe Union"
      ]
    ]
    "official" => "Europe Union"
  ]
  "name_alt" => ""
  "name_ciawf" => "Europe Union"
  "name_len" => "12.00"
  "name_long" => "Europe Union"
  "name_sort" => "Europe Union"
  "note_adm0" => ""
  "note_brk" => ""
  "postal" => ""
  "sovereignt" => "Europe Union"
  "su_a3" => "EUR"
  "su_dif" => "0.00"
  "subunit" => "Europe Union"
  "tiny" => "-99.00"
  "tld" => array:1 [
    0 => ".eu"
  ]
  "translations" => array:13 [
    "deu" => array:2 [
      "common" => "Frankreich"
      "official" => "Französische Republik"
    ]
    "est" => array:2 [
      "common" => "Prantsusmaa"
      "official" => "Prantsuse Vabariik"
    ]
    "fin" => array:2 [
      "common" => "Ranska"
      "official" => "Ranskan tasavalta"
    ]
    "fra" => array:2 [
      "common" => "Europe Union"
      "official" => "République française"
    ]
    "hrv" => array:2 [
      "common" => "Francuska"
      "official" => "Francuska Republika"
    ]
    "ita" => array:2 [
      "common" => "Francia"
      "official" => "Repubblica francese"
    ]
    "jpn" => array:2 [
      "common" => "フランス"
      "official" => "フランス共和国"
    ]
    "nld" => array:2 [
      "common" => "Frankrijk"
      "official" => "Franse Republiek"
    ]
    "por" => array:2 [
      "common" => "França"
      "official" => "República Francesa"
    ]
    "rus" => array:2 [
      "common" => "Франция"
      "official" => "Французская Республика"
    ]
    "slk" => array:2 [
      "common" => "Francúzsko"
      "official" => "Francúzska republika"
    ]
    "spa" => array:2 [
      "common" => "Francia"
      "official" => "República francés"
    ]
    "zho" => array:2 [
      "common" => "法国"
      "official" => "法兰西共和国"
    ]
  ]
  "un_a3" => "250"
  "wb_a2" => "EU"
  "wb_a3" => "EUR"
  "wikipedia" => "-99.00"
  "woe_id" => "-90.00"
  "woe_id_eh" => "23424819.00"
  "woe_note" => "Includes only Metropolitan France (including Corsica)"
  "hydrated" => array:1 [
    "flag" => true
  ]
]
ametad commented 3 years ago

https://github.com/antonioribeiro/countries/blob/b20491ee69f0b4f6fa3d633a25264c4ff777083d/src/data/countries/overload/eur.json#L174

Is this a joke or something? Sorry to be so blunt, but I find it very not funny that Europe is portrayed as the same as France in the translations... But perhaps I am missing something?

bpuig commented 3 years ago

Today I got into the package a bit and also found that. The EU is not a country but a union of them, and @ametad is right, the UE is not translated as "France".

How can we solve and remove this thing?

antonioribeiro commented 3 years ago

The readme states sometimes that this package is generated by a collection of other packages. If the data is somehow wrong, you need to contact them to fix it and, then, just run the update script to generate them all again. No data can be manually fixed here.

Please check the sources here: https://github.com/antonioribeiro/countries#copyright

ametad commented 3 years ago

@antonioribeiro Thank you for your feedback.