Comments (10)
Could you elaborate a bit more about what you mean by "refreshing the data using a script"?
Personally I think the data changes rarely at most, but definitely not "often" or "a lot". This is subjective though, of course. A patch version is easily created and released when that does happen. So I am not entirely sure this warrants such a complex approach to keeping the data up to date. What is your thought on this?
from iso3166.
Well I come from an area of the world were believe me these data changed a lot the last 10 years. And technically I find it strange to have to update a library while the only thing that have change is just the provided data. If I had a service that can do that in the package it would be better IMHO.
Also, by decoupling the data from the class you would have to inject it into the class which improve:
- testing
- make it simpler to use with historical or legacy or deprecated codes (which I believe are not present in your class)
That why I think decoupling the data is important and maybe having a service to retrieve this data from ISO would be awesome.
from iso3166.
Those are some valid arguments regarding decoupling. I will look into this when I have some more spare time :-)
retrieve this data from ISO
This unfortunately will not be as easy. Most of this data I gathered from wikipedia.org and iso.org by hand. Automating this might take a significant effort.
from iso3166.
at least for currency you have this service
http://www.currency-iso.org/dam/downloads/lists/list_one.xml
but for iso code its more difficult I could only found this link
http://www.iso.org/iso/home/store/publication_item.htm?pid=PUB500001%3aen
Seems getting access to this data freely from a trusted source is not that simple
from iso3166.
would be interesting to work out a way of versioning the data so that by default it loads the latest, but dev's could load up an older revision (i.e. they may be working with another system that isn't as up to date).
In addition to this (no it's not just a +1 post), it would be useful to be able to load up the data in various languages (see: https://en.wikipedia.org/wiki/List_of_country_names_in_various_languages_(A%E2%80%93C) ).
Obviously this turns into a mammoth content curation task if you can't automate it from a reliable source, however i think if you provide the schema for these things to be able to work, the community will help fill in the blanks as it get's used more (won't take a native speaker more than 10 minutes to run through and translate the country names in there own language after all).
Alternatively reddit i believe uses crowdin.com who give free OS licenses if you wanted to go down the gettext route
from iso3166.
Localization has always been on my personal todo-list yeah, so it will probably make it into this package eventually. Just need to find the time, and consider the various implementations possible :-)
from iso3166.
localisation is very simple to achieve using the intl extension If have a POC I'm working on but major bc in it :)
the difficult part is localization of the currencies
from iso3166.
There is no localization for the currencies as they are just linked by their ISO codes (which are language agnostic) o_O
from iso3166.
So I've here's my Proof of Concept .. feel free to dig in and to get what you like and trash what you don't like ... I didn't make any Test suite though so might be buggy
https://github.com/nyamsprod/iso3166/tree/feature/decoupling
Major BC break:
- introduce a CountryInterface and a Country implementation
- ISO3166 is a collection class which accept a array of Country object
- because Country is an object localization is done using PHP intl extension
- currencies are always arrays
and here's a simple usage
<?php
require 'vendor/autoload.php';
use League\ISO3166\ISO3166;
$data = require __DIR__.'/data/public-country-list.php';
$collection = ISO3166::createFromArray($data);
$country = $collection->getByAlpha3('SEN'); //returns a CountryInterface object
$country->toArray(); //convert the object into your "array" the name is missing
$country->getName(); //current locale may vary depending on your server settings
$country->getName('en'); // displays 'Senegal' the full name in english
$country->getName('fr'); // displays 'Sénégal' the full name in french
$country->getCurrencies(); //always an array because some countries may have multiple currencies legals at a given time
$country->getAlpha3();
$country->getAlpha2();
$country->getNumeric();
$country->hasCurrency('XOF'); //returns true detect if the currencies is legal in the country boolean
$country->hasCurrency('USD'); // returns false
$country->hasIsoCode('SN'); //returns true
$country->hasIsoCode('COD'); //return false
What's left is to get a good service manager to populate/maintain/update/ the public-country-list.php file/data.
from iso3166.
This change is too rigorous for my taste, sorry.
I would like to avoid wrapping the data in a 'Country' entity (or any other entity). I suspect most end users would like to create and use their own types/entities. This project simply aims at providing the data to populate those.
I do think it would be nice if the ISO3166
class had a constructor that accepted an array to replace the default value of $countries
. That would be a backwards-compatible step towards supporting localization.
from iso3166.
Related Issues (20)
- Avoid loading massive array in memory HOT 1
- country code for kosovo is added HOT 4
- Include other countries HOT 4
- PHP 8 Support HOT 2
- How to get the current country alpha2 to display on url
- Aliases HOT 5
- Project Name? HOT 1
- shouldn't the main API be static? HOT 1
- "Czech Republic" or "Czechia" (Alias -feature request) HOT 4
- PHP 8.1 Deprecation message HOT 2
- Missed Netherlands Antilles (feature request) HOT 2
- Language to be used for default locales
- New release to prevent deprecations triggered on PHP 8.1 HOT 4
- Freezes downloading on Composer install HOT 1
- Missing entry for Canary Islands HOT 2
- Canary Islands is not present in the library HOT 1
- It will be nice if structure can return Nationality also
- Croatia currency updated in 2023 HOT 1
- Make ISO3166 more "extendable" HOT 1
- Multibyte string extension does not described in composer.json schema. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iso3166.