mledoze / countries

World countries in JSON, CSV, XML and Yaml. Any help is welcome!

Home Page:https://mledoze.github.io/countries/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to make sense of dialing code out of "idd" property?

VictorQueiroz opened this issue · comments

In a previous version we had callingCode property but now this property is gone. idd is rather confusing to me.

For example: Brazil country code is 55 but it is now split into idd.root = 5 and then idd.suffixes = [5]. It doesn't make any sense to me.

Can someone explain to me how can I achieve original country code using this data?

Hello @VictorQueiroz,

it's rather simple: to construct the list of calling codes for a country, you need to concatenate the root part with each suffixes.

The reasoning behind the refactoring of the old callingCode property can be found in the original pull request.

This gave me an idea: we could recreate the old callingCode property at build time from the idd field, what do you think @VictorQueiroz?

This gave me an idea: we could recreate the old callingCode property at build time from the idd field, what do you think @VictorQueiroz?

Hi @mledoze,

sorry about the delay. I appreciate your initiative and attention with my issue. I think it'd be great to have that as a package that would use world-countries package underneath it. Seems less aggressive. :)

There is no need for another package. I can generate the calling codes only in the dist files which are generated from the data in the main countries.json.

👋 @VictorQueiroz it's done on master. I will release a new version by the end of this week.