Use a coherent county list, with ISO abbreviations in DB

Hi - just looking at this closed issue: https://github.com/mautic/mautic/issues/2112 which request the enhancement of using ISO country codes to describe countries rather than an arbitrary list of countries that don’t map well to any “authoritative” country list, which uses a hodgepodge of full (English, mostly) names as is currently the case.

I note that this lists is in app/bundles/CoreBundle/Assets/json/countries.json

This makes using the Contact API quite difficult when it comes to managing country assignments… because countries have to be specified using Mautic’s own quirky definitions… requiring complex mapping, across character encoding types, too, if one is unlucky.

I also note that there’re are localised country lists, mapped to ISO 2 letter country codes, in the codebase already, e.g. for the English locale: vendor/symfony/intl/Resources/data/regions/en.json

It’d be a huge help to have these ISO standards references stored in the DB rather than the arbitrary (and unlocaliseable) names as is currently the case (e.g. as stored in leads->country)… seems like it’d make Mautic devs’ lives easier too, by far… although it’ll be a painful transition in the short term.

Need to add additional tags…

This is an urgent need. Mautic needs to use a standard country name list. Most of integrations or implementations break because the country names do not match with the mautic list

1 Like

to better standard Mautic can use an iso3166 standard like this repo https://github.com/thephpleague/iso3166

or this one https://github.com/commerceguys/addressing

Heh, thanks for adding your voice @bellafronte - yeah, I’ve had to write a country translation layer substantially complicating my API implementation… So it’d be cool if this got fixed!

I understand your headache @lightweight just because Mautic call US United States, and not United States Of America, I need to get a way to translate all countries names. This is painful.

It is sad to know that Mautic advances in so many novelties but with simple questions like this one is given no attention. I meet requests for more than 3 years for this problem and nothing is changed.

Yes, it’s a problem… Mautic is an impressive tool… but it has some very strange blind spots… I wish, for example, that these issues were in a Git project system (like a Gitlab) rather than in a forum…

Given how deeply embedded this country stuff is within their data schema (they store country names in the DB, rather than indices into a country table!) it’d be a total nightmare to fix this architectural problem… So, I feel some sympathy for the Mautic dev team having to wrestle with such an unfortunate early decision, no doubt made out of expedience, to define their own country list… :frowning:

For what it’s worth, I wrote a parser (in PHP) to create the mapping between an ISO country list (using 2 letter country codes mapped to full names) and the Mautic-specific country list… note, it’s not a strict 1-to-1 mapping.

1 Like

@lightweight Mautic uses two JSON files to which provide the country and states names. They are located in /app/bundles/CoreBundle/Assets/json/countries.json and /app/bundles/CoreBundle/Assets/json/regions.json

1 Like

Maybe this dataset can help you https://datahub.io/core/country-list

Hello,

I need to interface Mautic with PayPal. They put country code for the USA as “us”.

In Mautic tables, the USA is coded as “United States”.

So, the “us” code is marked as invalid and the value is not preserved.

I just want to be able to write whatever PayPal has to say.

How can I do that?

Thank you,

Michael

Has there been any updates on this?

As we do more integrations and get more customers in more countries, this is creating an issue as we are having to drop both country and state from our api updates from our ecomm front end to Mautic using our middleware.

All of our transactional systems are using ISO-2 naming conventions. IE US CA for United States, California.

Yes, Yes and YES. This needs changing immediately. It’s been way too long, just spent hours trying to map this to simply communicate between two apps. Still doesn’t work. THIS IS PAINFUL!!!

The best would be to change in the core yes. Until this happens, try to help yourself with this: GitHub - mzagmajster/mautic-iso-code-bundle: Convert Mautic Country to ISO code

Thank you trying to get it to install. What exactly should this line be??

git clone <repo-url> MZagmajsterIsoCodeBundle

Not sure if I have composer installed. Is this required? If so, is there a link to tell me how this is done?

I mean you probably can get it to work with the composer.

But otherwise instructions are in the readme.

ok I unzipped and uploaded it via ftp, cleared cache then tried installing it via the plugins page on mautic. Clicked the install button but nothing yet…