iso3166 icon indicating copy to clipboard operation
iso3166 copied to clipboard

Need for country common name

Open 8ctopus opened this issue 1 year ago • 5 comments

The following code:

$countryCode = 'GB';

$iso = (new ISO3166())
    ->alpha2($countryCode);

/** @disregard P1013 */
$buyer = (new Person())
    ->setFirstName($firstName)
    ->setLastName($lastName)
    ->setStreet1($street1)
    ->setStreet2($street2)
    ->setZip($zip)
    ->setCity($city)
    ->setCountry($iso['name'])
    ->setEmail($email);

will end up with something like this in an invoice:

John Doe
St. Johns Street
SS69DQ RAYLEIGH
United Kingdom of Great Britain and Northern Ireland

This is not convenient for invoices as it will end up making the buyer's address field way too long as shown in this screenshot from a pdf:

image

It's common practice to use the common name as the Wikipedia article intro explains: The United Kingdom of Great Britain and Northern Ireland, commonly known as the United Kingdom (UK).

So the idea is to add the common name when it differs from the official one to the array.

        [
            'name' => 'United Kingdom of Great Britain and Northern Ireland',
            'common' => 'United Kingdom',
            'alpha2' => 'GB',
            'alpha3' => 'GBR',
            'numeric' => '826',
            'currency' => [
                'GBP',
            ],
        ],

If you agree to this update, I will happily provide a PR.

8ctopus avatar Oct 24 '24 07:10 8ctopus

I'm actually not sure if I want to maintain this library much longer. Packages such as symfony/intl are much more complete.

alcohol avatar Oct 24 '24 11:10 alcohol

@alcohol With 28M downloads and counting that would be a shame. I'm happy to help you with maintenance if you want. You can review my github repositories and see if I'm a fit. Please let me know if I should create a PR.

8ctopus avatar Oct 24 '24 13:10 8ctopus

Sorry it took so long to get back to this. A PR is welcome, though it would help if there was a good source for a list of such names. I have not yet been able to find a comprehensive one.

alcohol avatar Feb 03 '25 09:02 alcohol

@alcohol Sorry, I switched to symfony/intl since I didn't hear back from you. I had some issues with the symfony library but in the end it works almost as good as yours.

8ctopus avatar Feb 03 '25 15:02 8ctopus

Understandable, glad to hear symfony/intl worked out for you in the end.

alcohol avatar Feb 04 '25 13:02 alcohol