CLDR and country calling codes / telephone codes

I create this new thread for a discussion that had started in another thread where we went off-topic:


So I’m new to CLDR and I’ve seen on the website that the database contains telephone codes:
CLDR Features - CLDR - Unicode Common Locale Data Repository (under country information, last bullet point).
However there’s no way to retrieve a country calling code with ex_cldr and its friends?
I guess this should be in cldr_territories but it’s not included.


CLDR has deprecated telephone code data so it hasn’t been included in any ex_cldr or related library to my knowledge.
Depending on your requirements you might find ex_phone_number meets your needs. If you’re after a wrapper for Google’s libphonenumber which is the canonical library for parsing, formatting, and validating international phone numbers you might find elibphonenumber closer to your requirement although it is a NIF so has a more complex build process.
Lastly, if none of these meets your needs, let me know what the use case is - its an interesting topic (like postal codes) but just not currently top of my list of things to do.

@kip I can share you the use case, when asking for a phone number, I ask the user the country calling code and the number separately, with two fields, e.g. <+32> <454134387>.

The mapping between an iso country code (“BE”) and the country calling code (“32”) and the country calling codes list are interesting for two cases for me:

  1. pre-fill the country calling code field according to the user’s location
    => map “BE” to “+32”
  2. validate that the filled country calling code exists (changeset validation)
    => find in list of country calling codes

We will publish a small library to get this mapping and this list, but we do not want to re-invent the wheel if this had been done in CLDR. You already answered this list is not supported.
You mentioned though that’s an interesting topic, but if the telephone codes have been deprecated in CLDR, I guess you can’t really do anything?
By the way, do you know why it has been deprecated or where I can find the notice?

The deprecation was in CLDR 34 in 2018.It says:

  • Deprecated the telephone number elements and removed telephoneCodeData.xml from CLDR [#10383]

That ticket says:

No longer kept up to date, and there are better open-source solutions

I try to be pragmatic in I8n and L10n. Adding mapping between territory codes and calling code prefixes is pretty straight forward to add. I’ll take a look at doing that over the weekend.

1 Like

ex_phone_number has a function ExPhoneNumber.Metadata.get_country_code_for_region_code/1 which does the mapping you want I think.


Thanks @kip that helps :+1: