Coder Social home page Coder Social logo

rinvex / countries Goto Github PK

View Code? Open in Web Editor NEW
1.6K 43.0 205.0 7.02 MB

Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

Home Page: https://rinvex.com

License: MIT License

PHP 100.00%
php countries capitals flags

countries's People

Contributors

andreybolonin avatar dependabot-preview[bot] avatar dspeichert avatar ker0x avatar lukasmu avatar madacol avatar ms-zlab avatar netcode avatar ninjahza avatar omranic avatar optiman avatar peterquentin avatar piskvor avatar rattone avatar scsheriftarek avatar sigmoidal avatar simoheinonen avatar thijskok avatar vinkla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

countries's Issues

Flag is very large

Can I change the size of the flag cause it's very large 750 widths and 500 height?

States of Mexico update

Hi, i just noticed that there's still Distrito Federal/DIF in the Mexico divisions json, but since 2016 it ceased to be called like that; Now it's Ciudad de México/CMX.

Just to let you know, hope you can update it soon 👍.

Fix wrong CountryLoaderException namespace

CountryLoaderException exception currently located under the Rinvex\Country while it's placed inside the src/Exceptions directory, so it's namespace must be fixed to be Rinvex\Country\Exceptions

Package still being maintained?

Hey,

I was just wondering if rinvex/country is still being actively maintained? If not, would you be interested in handing off maintenance to someone else?

Add timezone & locale data for countries

It would be nice to have something like the following data for each country:

{
    "DefaultLanguageCode": "en",
    "TimeZones": [
        "America/New_York",
        "America/Chicago",
        "America/Denver",
        "America/Phoenix",
        "America/Los_Angeles"
    ],
    "Locales": [
        "en_US"
    ]
}

Error on getTld() method

Hi
Found a case where getTld() throws an error:

[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: current() expects parameter 1 to be array, null given

[2017-09-12 07:40:18] local.ERROR: Type error: current() expects parameter 1 to be array, null given {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Type error: current() expects parameter 1 to be array, null given at /var/www/projects/translations/vendor/rinvex/country/src/Country.php:249)

Case 1 - Works OK

$country = country('XK');
dd($country->getTld());

Case 2 - Works OK

$country = country('XK', false);
dd($country['tld']);

Case 3 - Works OK

$countries = countries(true);
foreach ($countries as $country) {
    dump($country['tld']);
}

Case 4 - Throws the error

$countries = countries(true, true);
foreach ($countries as $country) {
    dump($country->getTld());
}

The error only occurs for XK - Kosovo, BQ - Caribbean Netherlands and SH - Saint Helena because the get() method returns null.

Replacing return current($this->get('tld', [])) ?: null; with return $this->get('tld', []) ?: null; seems to fix the error.

Cheers

Long-term data reliability

For the past year or two, I've been using a custom countries database table, so that my users can be associated with a country_id. However, I'm becoming more and more fond of this library, and am finding that more and more I'm using this instead of my own table for things other than long-term database storage.

Now; my question has to do with the long-term usage of this library. If I were to slowly migrate away from having a countries table and using this library instead (via a custom wrapper), what would be the most reasonable 'key' to identify a country? Should users have a country_code that contains the ISO 3166 Alpha-2 instead? Or the ISO 3166 Numeric? Or something else? What would be the most reasonable long-term 'key' here?

Feature: 'phone_format'

Just like 'address_format', just one for numbers.

Example:
+352 691 123 4567
// {{callingcode}} {{initial}} {{range1}} {{range2}}

I don't know the actual names, but basically that.

England fifa codes

Hi,

Why does england has 4 fifa codes and not just ENG? according to wikipedia it should only be ENG.

Fix default currency for all countries

Some countries has multiple currencies, but mostly only one is used or at least there's a default currency, but this package returns the first currency regardless, which make it weird.

We need to sort currencies and change the default behavior to return the official/default currency of the country, and if needed all other currencies will be returned optionally. Related issue #52

Add missing country divisions

There's still missing divisions for the following countries:

  • ai: Anguilla
  • aq: Antarctica
  • as: American Samoa
  • aw: Aruba
  • ax: Åland Islands
  • bl: Saint Barthélemy
  • bm: Bermuda
  • bv: Bouvet Island
  • cc: Cocos (Keeling) Islands
  • ck: Cook Islands
  • cw: Curaçao
  • cx: Christmas Island
  • fk: Falkland Islands
  • fo: Faroe Islands
  • gf: French Guiana
  • gg: Guernsey
  • gi: Gibraltar
  • gl: Greenland
  • gp: Guadeloupe
  • gs: South Georgia
  • gu: Guam
  • hk: Hong Kong
  • hm: Heard Island and McDonald Islands
  • im: Isle of Man
  • io: British Indian Ocean Territory
  • je: Jersey
  • lc: Saint Lucia
  • mc: Monaco
  • mf: Saint Martin
  • mo: Macau
  • mp: Northern Mariana Islands
  • mq: Martinique
  • ms: Montserrat
  • nc: New Caledonia
  • nf: Norfolk Island
  • nu: Niue
  • pf: French Polynesia
  • pm: Saint Pierre and Miquelon
  • pn: Pitcairn Islands
  • pr: Puerto Rico
  • ps: Palestine
  • re: Réunion
  • sj: Svalbard and Jan Mayen
  • ss: South Sudan
  • sx: Sint Maarten
  • tc: Turks and Caicos Islands
  • tk: Tokelau
  • va: Vatican City
  • vg: British Virgin Islands
  • vi: United States Virgin Islands
  • wf: Wallis and Futuna
  • xk: Kosovo
  • yt: Mayotte

how to get country list by languages only ?

i try to do this
\Rinvex\Country\CountryLoader::where('languages', 'Arabic');

but its not working
even i try with passing an array ['value' => 'Arabic']
but also same issue

can anyone help me with this

thank you.

Countries with multiple divisions levels

GB has multiple division levels, and currently the dataset has all divisions levels combined into one.
Eg. Derby and Derbyshire exist in the one list.

This seems to be an issue that has stemmed from https://github.com/hexorx/countries
Would be nice if this could be fixed, other countries may be affected as well.

If my need becomes more pressing, I will make a pull request to fix GB divisions.
But this will need to be properly looked into for all countries.

JP: Different format if using latin

This popped up in production for us:

Some japanese users type their adresses using latin characters instead of katakana, and per the recommendations (https://www.post.japanpost.jp/int/use/writing/ems_en.html) such addressing should be reversed (ie the traditional "western" addressing system, ie name, followed by street, followed by zip and city etc).

It also gets quite confusing when westernized addresses are used since the JP format looks like this:
〒{{postalcode}}\n{{region_short}}{{city}}{{street}}\n{{recipient}}\n{{country}}
ie, no separator between region, city and street.

So maybe we need a jp-westernized.json file, with a format something along the lines of
{{recipient}}\n{{street}}\n{{postalcode}}{{city}}\n{{region_short}}\n{{country}}

As to how we would select that format instead of the official JP one I'm not sure. A helper function to analyze if the address contains mostly latin characters or not maybe? Or just a flag to pass (westernized=true)?

Translations of divisons

Are there any plans in making the alternative names of the division as translations, where i can map the alternative name to a language? I think the default name of a divison is in the native language, but how do i know which alternative name is for what language?

PHP Fatal error: Class 'Rinvex\Country\CountryLoaderException' not found

.PHP Fatal error:  Class 'Rinvex\Country\CountryLoaderException' not found in E:\www\labs\shipment-tracking\vendor\rinvex\country\src\Loader.php on line 219

Version: 2.0.0

I know its has been fixed in v3; because of my php version, i can only use v2; will you relase a fix version for v2?

Some currency doesn't correct

There are 4 countries returns incorrect Currency.

>>> country('us')->getCurrency()
=> [
     "iso_4217_code" => "USN",
     "iso_4217_numeric" => 997,
     "iso_4217_name" => "United States dollar (next day) (funds code)",
     "iso_4217_minor_unit" => 2,
   ]
>>> country('us')->getCurrencies()
=> [
     "USN" => [
       "iso_4217_code" => "USN",
       "iso_4217_numeric" => 997,
       "iso_4217_name" => "United States dollar (next day) (funds code)",
       "iso_4217_minor_unit" => 2,
     ],
     "USS" => [
       "iso_4217_code" => "USS",
       "iso_4217_numeric" => 998,
       "iso_4217_name" => "United States dollar (same day) (funds code)",
       "iso_4217_minor_unit" => 2,
     ],
     "USD" => [
       "iso_4217_code" => "USD",
       "iso_4217_numeric" => 840,
       "iso_4217_name" => "US Dollar",
       "iso_4217_minor_unit" => 2,
     ],
   ]

Should return USD, but first one USN returned.

country('us')->getCurrency()
country('cl')->getCurrency()
country('uy')->getCurrency()
country('bo')->getCurrency()

there are 4 countries return incorrect currency.

Drop PHP 5.5/5.6 support

Since PHP 5.5 already out of date and no longer supported, and 5.6's EOL is just in few days, we've to require PHP 7.0 as the minimum requirement for this package, we're aware this is a a breaking change for some, so we plan to bump package's version to next major release for that update v3.0.0. If you don't plan to update to PHP 7+ soon, then keep using the v2 version of this package.

Caribbean Netherlands / Curaçao dailling code issues

Reference: Fahed Bizzari

Thanks for developing the country library. We're about to replace lots of our code with it.

However, there are a couple of issues:

  1. Caribbean Netherlands (BQ) should have a dialling code of +599 (see here)
  2. Curaçao (CW) should have a dialling code +599 not +5999.

Any way for you guys to get these updated?

[Proposal] Currency Symbols

Hi all,

It would be useful to return the currency symbol in Hex and/or Dec format - I'm not sure if there's an automated source/way of integration into the existing json files. My thoughts were for the currency object to look something like;

{
	"GBP": {
		"iso_4217_code": "GBP",
		"iso_4217_numeric": 826,
		"iso_4217_name": "Pound sterling",
		"iso_4217_minor_unit": 2,
		"symbols": {
			"hex": "xa3",
			"dec": 163
		}
	}
}

Beautify all JSON files & add production mode compilation command

Currently all JSON files are compressed, which make it difficult to review PRs and check differences between revisions or even read source files humanly, it's compressed for the sake of size saving on production, but we can do better.

We'll convert all JSON files into well formatted source files, and will add command line tool to compile these files for production usage (optional).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.