Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Intl component - missing region #47825

Closed
Closed
@trsteel88

Description

@trsteel88

Symfony version(s) affected

6.*

Description

I have a application which was recently upgraded from Symfony 3.4 to 6 and I have noticed that there is a region missing from the Intl component.

The region that I have found was "AC" - https://github.com/symfony/intl/blob/3.4/Resources/data/regions/en.json#L3

Within the application, we have the following method:

public function getCountryName(): ?string
    {
        if (null === $this->country) {
            return null;
        }

        return Countries::getName($this->country);
    }

However, this now throws a Symfony\Component\Intl\Exception\MissingResourceException exception.

The only option for us is to catch this exception and return the code instead:

public function getCountryName(): ?string
    {
        if (null === $this->country) {
            return null;
        }

        try {
            return Countries::getName($this->country);
        } catch (MissingResourceException $e) {
            return $this->country;
        }
    }

It seems odd that this region has disappeared when it still exists here: https://www.iso.org/obp/ui/#iso:code:3166:AC

How to reproduce

echo \Symfony\Component\Intl\Countries::getName('AC');

Possible Solution

Load "AC" and any other missing regions back into the Intl php arrays. Unless this was intentionally removed?

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions