Open elskwid opened 14 years ago
I agree that something needs to be done about this. I'd be willing to re-extract the data from the above url, but it seems the issue lies in the YAML "key" being the same as the :country_code. I would content that the key simply needs to be a unique (incrementing?) value, thereby allowing multiple countries to share a country_code.
@sterrym: the trouble with sharing a country_code is that the parsing is keyed off the country_code - so how would the library decide what parsing rules to use?
The point seems to be that in some cases the dialing rules span "country" boundaries. My example about Australia vs Cocos Islands means that you dial the Cocos just like you would Australia and use the "area code" for the Cocos - it's a subset of the Australian phone system.
@eskwid I'm not saying that there shouldn't be a country_code. I would argue that the country_code doesn't also have to be the key for the yml-created hash. The commondatahub link you provided above lists 24 countries that all share the "1" country_code. with that number of countries getting clobbered, I would contend that it's worth finding a different way.
The only method I can see that uses this as a key is this in phone_country.rb:
def self.find_by_country_code(code)
@@all[code]
end
In my use case, I am developing for a Canadian client with customers all over the world. It's not really an option for them to only have the United States listed for the "1" code.
So I suppose the question is, do all the countries that share the "1" country_code also have the same formatting/parsing rules? If not, then we can still limp by with this. If so, then it gets harder.
All countries using the "1" country code use the same formatting rules.
Once issue 29 has been addressed, I'll fix up some of the other problems after re-base of repo.
All countries using the "1" country code use the same formatting rules.
Once issue 29 has been addressed, I'll fix up some of the other problems after re-base of repo; though I hate having to wait two weeks already to do this.
Looks like hell will freeze over before I get an answer. Issue 29 still awaits review.
Hey guys, been a long time! I'm going to making a pass through issues soon. See #41.
I have user-originated phone numbers with a mix of "phone / tel / ..." in front or at the end of my strings, and I need to support Norway (curently clobbered as described above). Is it only the data import feature and elf.find_by_country_code(code) that is affected? Sounds easy to fix. Patches welcome?
It seems the data extraction from http://commondatahub.com/live/geography/country/country_dialing_codes may have had a couple of issues.
There are multiple instances of countries sharing a country code. US & Canada are a good example. Today I was looking for Australia in phone_countries.yml and found
Turns out Cocos is a territory of Australia (Thanks Wikipedia!).
I also see that Norway is not in the file, but Svalbard is. My guess is that the data extraction just overwrote previous country code entries as it progressed. Which means we got luck with the US and Italy as Italy and the Holy See share a code.
Sorting the commondatahub table on dialing country code shows some others.
My first instinct is to just change the offending entires in phone_countries.yml to the more commonly recognized countries. However, this doesn't make much sense if the countries file is going to be automatically regenerated in the future.