<?php
namespace App\Entity\Localisation;
use App\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\Localisation\CountryInfoRepository")
* @ORM\Table(name="country_info", indexes={
* @ORM\Index(name="idx_country_iso", columns={"iso_code"}),
* @ORM\Index(name="idx_geoname_id", columns={"geoname_id"}),
* @ORM\Index(name="idx_currency_code", columns={"currency_code"})
* })
*/
class CountryInfo
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=2, unique=true)
*/
private $isoCode;
/**
* @ORM\Column(type="string", length=3)
*/
private $iso3Code;
/**
* @ORM\Column(type="string", length=100)
*/
private $countryName;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $capital;
/**
* @ORM\Column(type="string", length=3, nullable=true)
*/
private $currencyCode;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $currencyName;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $languages;
/**
* @ORM\Column(type="string", length=2, nullable=true)
*/
private $continent;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $population;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $area;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $tld;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $phoneCode;
/**
* @ORM\Column(type="integer", unique=true)
*/
private $geonameId;
/**
* @ORM\Column(type="string", length=500, nullable=true)
*/
private $neighbours;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $lastUpdated;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="country")
*/
private $users;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $countryNameFr;
public function __construct()
{
$this->lastUpdated = new \DateTime();
$this->users = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIsoCode(): ?string
{
return $this->isoCode;
}
public function setIsoCode(string $isoCode): self
{
$this->isoCode = $isoCode;
return $this;
}
public function getIso3Code(): ?string
{
return $this->iso3Code;
}
public function setIso3Code(string $iso3Code): self
{
$this->iso3Code = $iso3Code;
return $this;
}
public function getCountryName(): ?string
{
return $this->countryName;
}
public function setCountryName(string $countryName): self
{
$this->countryName = $countryName;
return $this;
}
public function getCapital(): ?string
{
return $this->capital;
}
public function setCapital(?string $capital): self
{
$this->capital = $capital;
return $this;
}
public function getCurrencyCode(): ?string
{
return $this->currencyCode;
}
public function setCurrencyCode(?string $currencyCode): self
{
$this->currencyCode = $currencyCode;
return $this;
}
public function getCurrencyName(): ?string
{
return $this->currencyName;
}
public function setCurrencyName(?string $currencyName): self
{
$this->currencyName = $currencyName;
return $this;
}
public function getLanguages(): ?string
{
return $this->languages;
}
public function setLanguages(?string $languages): self
{
$this->languages = $languages;
return $this;
}
/**
* Retourne un tableau des langues parlées
*/
public function getLanguagesArray(): array
{
if (!$this->languages) {
return [];
}
return array_map('trim', explode(',', $this->languages));
}
/**
* Retourne la langue principale (première dans la liste)
*/
public function getPrimaryLanguage(): ?string
{
$languages = $this->getLanguagesArray();
if (empty($languages)) {
return null;
}
// Extrait le code de langue (avant le tiret s'il y en a un)
$firstLang = $languages[0];
if (strpos($firstLang, '-') !== false) {
return substr($firstLang, 0, strpos($firstLang, '-'));
}
return $firstLang;
}
public function getContinent(): ?string
{
return $this->continent;
}
public function setContinent(?string $continent): self
{
$this->continent = $continent;
return $this;
}
public function getPopulation(): ?int
{
return $this->population;
}
public function setPopulation(?int $population): self
{
$this->population = $population;
return $this;
}
public function getArea(): ?float
{
return $this->area;
}
public function setArea(?float $area): self
{
$this->area = $area;
return $this;
}
public function getTld(): ?string
{
return $this->tld;
}
public function setTld(?string $tld): self
{
$this->tld = $tld;
return $this;
}
public function getPhoneCode(): ?string
{
return $this->phoneCode;
}
public function setPhoneCode(?string $phoneCode): self
{
$this->phoneCode = $phoneCode;
return $this;
}
public function getGeonameId(): ?int
{
return $this->geonameId;
}
public function setGeonameId(int $geonameId): self
{
$this->geonameId = $geonameId;
return $this;
}
public function getNeighbours(): ?string
{
return $this->neighbours;
}
public function setNeighbours(?string $neighbours): self
{
$this->neighbours = $neighbours;
return $this;
}
/**
* Retourne un tableau des pays voisins
*/
public function getNeighboursArray(): array
{
if (!$this->neighbours) {
return [];
}
return array_map('trim', explode(',', $this->neighbours));
}
public function getLastUpdated(): ?\DateTimeInterface
{
return $this->lastUpdated;
}
public function setLastUpdated(?\DateTimeInterface $lastUpdated): self
{
$this->lastUpdated = $lastUpdated;
return $this;
}
/**
* Met à jour le timestamp de dernière modification
*/
public function updateTimestamp(): self
{
$this->lastUpdated = new \DateTime();
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setCountry($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getCountry() === $this) {
$user->setCountry(null);
}
}
return $this;
}
public function getCountryNameFr(): ?string
{
return $this->countryNameFr;
}
public function setCountryNameFr(?string $countryNameFr): self
{
$this->countryNameFr = $countryNameFr;
return $this;
}
/**
* Met à jour le nom français du pays à partir du nom anglais
* Utilise l'extension Intl de PHP pour obtenir la traduction française
*/
public function updateCountryNameFr(): self
{
if (!$this->countryName) {
return $this;
}
// Mapping basé sur les noms anglais exacts (plus fiable)
$countryNameMapping = [
'Andorra' => 'Andorre',
'United Arab Emirates' => 'Émirats arabes unis',
'Afghanistan' => 'Afghanistan',
'Antigua and Barbuda' => 'Antigua-et-Barbuda',
'Anguilla' => 'Anguilla',
'Albania' => 'Albanie',
'Armenia' => 'Arménie',
'Angola' => 'Angola',
'Antarctica' => 'Antarctique',
'Argentina' => 'Argentine',
'American Samoa' => 'Samoa américaines',
'Austria' => 'Autriche',
'Australia' => 'Australie',
'Aruba' => 'Aruba',
'Aland Islands' => 'Îles Åland',
'Azerbaijan' => 'Azerbaïdjan',
'Bosnia and Herzegovina' => 'Bosnie-Herzégovine',
'Barbados' => 'Barbade',
'Bangladesh' => 'Bangladesh',
'Belgium' => 'Belgique',
'Burkina Faso' => 'Burkina Faso',
'Bulgaria' => 'Bulgarie',
'Bahrain' => 'Bahreïn',
'Burundi' => 'Burundi',
'Benin' => 'Bénin',
'Saint Barthelemy' => 'Saint-Barthélemy',
'Bermuda' => 'Bermudes',
'Brunei' => 'Brunei',
'Bolivia' => 'Bolivie',
'Bonaire, Saint Eustatius and Saba ' => 'Bonaire, Saint-Eustache et Saba',
'Brazil' => 'Brésil',
'Bahamas' => 'Bahamas',
'Bhutan' => 'Bhoutan',
'Bouvet Island' => 'Île Bouvet',
'Botswana' => 'Botswana',
'Belarus' => 'Biélorussie',
'Belize' => 'Belize',
'Canada' => 'Canada',
'Cocos Islands' => 'Îles Cocos',
'Democratic Republic of the Congo' => 'République démocratique du Congo',
'Central African Republic' => 'République centrafricaine',
'Republic of the Congo' => 'République du Congo',
'Switzerland' => 'Suisse',
'Ivory Coast' => 'Côte d\'Ivoire',
'Cook Islands' => 'Îles Cook',
'Chile' => 'Chili',
'Cameroon' => 'Cameroun',
'China' => 'Chine',
'Colombia' => 'Colombie',
'Costa Rica' => 'Costa Rica',
'Cuba' => 'Cuba',
'Cabo Verde' => 'Cap-Vert',
'Curacao' => 'Curaçao',
'Christmas Island' => 'Île Christmas',
'Cyprus' => 'Chypre',
'Czechia' => 'Tchéquie',
'Germany' => 'Allemagne',
'Djibouti' => 'Djibouti',
'Denmark' => 'Danemark',
'Dominica' => 'Dominique',
'Dominican Republic' => 'République dominicaine',
'Algeria' => 'Algérie',
'Ecuador' => 'Équateur',
'Estonia' => 'Estonie',
'Egypt' => 'Égypte',
'Western Sahara' => 'Sahara occidental',
'Eritrea' => 'Érythrée',
'Spain' => 'Espagne',
'Ethiopia' => 'Éthiopie',
'Finland' => 'Finlande',
'Fiji' => 'Fidji',
'Falkland Islands' => 'Îles Malouines',
'Micronesia' => 'Micronésie',
'Faroe Islands' => 'Îles Féroé',
'France' => 'France',
'Gabon' => 'Gabon',
'United Kingdom' => 'Royaume-Uni',
'Grenada' => 'Grenade',
'Georgia' => 'Géorgie',
'French Guiana' => 'Guyane française',
'Guernsey' => 'Guernesey',
'Ghana' => 'Ghana',
'Gibraltar' => 'Gibraltar',
'Greenland' => 'Groenland',
'Gambia' => 'Gambie',
'Guinea' => 'Guinée',
'Guadeloupe' => 'Guadeloupe',
'Equatorial Guinea' => 'Guinée équatoriale',
'Greece' => 'Grèce',
'South Georgia and the South Sandwich Islands' => 'Géorgie du Sud-et-les Îles Sandwich du Sud',
'Guatemala' => 'Guatemala',
'Guam' => 'Guam',
'Guinea-Bissau' => 'Guinée-Bissau',
'Guyana' => 'Guyana',
'Hong Kong' => 'Hong Kong',
'Heard Island and McDonald Islands' => 'Îles Heard-et-MacDonald',
'Honduras' => 'Honduras',
'Croatia' => 'Croatie',
'Haiti' => 'Haïti',
'Hungary' => 'Hongrie',
'Indonesia' => 'Indonésie',
'Ireland' => 'Irlande',
'Israel' => 'Israël',
'Isle of Man' => 'Île de Man',
'India' => 'Inde',
'British Indian Ocean Territory' => 'Territoire britannique de l\'océan Indien',
'Iraq' => 'Irak',
'Iran' => 'Iran',
'Iceland' => 'Islande',
'Italy' => 'Italie',
'Jersey' => 'Jersey',
'Jamaica' => 'Jamaïque',
'Jordan' => 'Jordanie',
'Japan' => 'Japon',
'Kenya' => 'Kenya',
'Kyrgyzstan' => 'Kirghizistan',
'Cambodia' => 'Cambodge',
'Kiribati' => 'Kiribati',
'Comoros' => 'Comores',
'Saint Kitts and Nevis' => 'Saint-Kitts-et-Nevis',
'North Korea' => 'Corée du Nord',
'South Korea' => 'Corée du Sud',
'Kosovo' => 'Kosovo',
'Kuwait' => 'Koweït',
'Cayman Islands' => 'Îles Caïmans',
'Kazakhstan' => 'Kazakhstan',
'Laos' => 'Laos',
'Lebanon' => 'Liban',
'Saint Lucia' => 'Sainte-Lucie',
'Liechtenstein' => 'Liechtenstein',
'Sri Lanka' => 'Sri Lanka',
'Liberia' => 'Liberia',
'Lesotho' => 'Lesotho',
'Lithuania' => 'Lituanie',
'Luxembourg' => 'Luxembourg',
'Latvia' => 'Lettonie',
'Libya' => 'Libye',
'Morocco' => 'Maroc',
'Monaco' => 'Monaco',
'Moldova' => 'Moldavie',
'Montenegro' => 'Monténégro',
'Saint Martin' => 'Saint-Martin',
'Madagascar' => 'Madagascar',
'Marshall Islands' => 'Îles Marshall',
'North Macedonia' => 'Macédoine du Nord',
'Mali' => 'Mali',
'Myanmar' => 'Myanmar',
'Mongolia' => 'Mongolie',
'Macao' => 'Macao',
'Northern Mariana Islands' => 'Îles Mariannes du Nord',
'Martinique' => 'Martinique',
'Mauritania' => 'Mauritanie',
'Montserrat' => 'Montserrat',
'Malta' => 'Malte',
'Mauritius' => 'Maurice',
'Maldives' => 'Maldives',
'Malawi' => 'Malawi',
'Mexico' => 'Mexique',
'Malaysia' => 'Malaisie',
'Mozambique' => 'Mozambique',
'Namibia' => 'Namibie',
'New Caledonia' => 'Nouvelle-Calédonie',
'Niger' => 'Niger',
'Norfolk Island' => 'Île Norfolk',
'Nigeria' => 'Nigeria',
'Nicaragua' => 'Nicaragua',
'The Netherlands' => 'Pays-Bas',
'Norway' => 'Norvège',
'Nepal' => 'Népal',
'Nauru' => 'Nauru',
'Niue' => 'Niue',
'New Zealand' => 'Nouvelle-Zélande',
'Oman' => 'Oman',
'Panama' => 'Panama',
'Peru' => 'Pérou',
'French Polynesia' => 'Polynésie française',
'Papua New Guinea' => 'Papouasie-Nouvelle-Guinée',
'Philippines' => 'Philippines',
'Pakistan' => 'Pakistan',
'Poland' => 'Pologne',
'Saint Pierre and Miquelon' => 'Saint-Pierre-et-Miquelon',
'Pitcairn' => 'Pitcairn',
'Puerto Rico' => 'Porto Rico',
'Palestinian Territory' => 'Palestine',
'Portugal' => 'Portugal',
'Palau' => 'Palaos',
'Paraguay' => 'Paraguay',
'Qatar' => 'Qatar',
'Reunion' => 'La Réunion',
'Romania' => 'Roumanie',
'Serbia' => 'Serbie',
'Russia' => 'Russie',
'Rwanda' => 'Rwanda',
'Saudi Arabia' => 'Arabie saoudite',
'Solomon Islands' => 'Îles Salomon',
'Seychelles' => 'Seychelles',
'Sudan' => 'Soudan',
'South Sudan' => 'Soudan du Sud',
'Sweden' => 'Suède',
'Singapore' => 'Singapour',
'Saint Helena' => 'Sainte-Hélène',
'Slovenia' => 'Slovénie',
'Svalbard and Jan Mayen' => 'Svalbard et Jan Mayen',
'Slovakia' => 'Slovaquie',
'Sierra Leone' => 'Sierra Leone',
'San Marino' => 'Saint-Marin',
'Senegal' => 'Sénégal',
'Somalia' => 'Somalie',
'Suriname' => 'Suriname',
'Sao Tome and Principe' => 'São Tomé-et-Príncipe',
'El Salvador' => 'Salvador',
'Sint Maarten' => 'Saint-Martin',
'Syria' => 'Syrie',
'Eswatini' => 'Eswatini',
'Turks and Caicos Islands' => 'Îles Turques-et-Caïques',
'Chad' => 'Tchad',
'French Southern Territories' => 'Terres australes françaises',
'Togo' => 'Togo',
'Thailand' => 'Thaïlande',
'Tajikistan' => 'Tadjikistan',
'Tokelau' => 'Tokelau',
'Timor Leste' => 'Timor oriental',
'Turkmenistan' => 'Turkménistan',
'Tunisia' => 'Tunisie',
'Tonga' => 'Tonga',
'Turkey' => 'Turquie',
'Trinidad and Tobago' => 'Trinité-et-Tobago',
'Tuvalu' => 'Tuvalu',
'Taiwan' => 'Taïwan',
'Tanzania' => 'Tanzanie',
'Ukraine' => 'Ukraine',
'Uganda' => 'Ouganda',
'United States Minor Outlying Islands' => 'Îles mineures éloignées des États-Unis',
'United States' => 'États-Unis',
'Uruguay' => 'Uruguay',
'Uzbekistan' => 'Ouzbékistan',
'Vatican' => 'Vatican',
'Saint Vincent and the Grenadines' => 'Saint-Vincent-et-les-Grenadines',
'Venezuela' => 'Venezuela',
'British Virgin Islands' => 'Îles Vierges britanniques',
'U.S. Virgin Islands' => 'Îles Vierges américaines',
'Vietnam' => 'Viêt Nam',
'Vanuatu' => 'Vanuatu',
'Wallis and Futuna' => 'Wallis-et-Futuna',
'Samoa' => 'Samoa',
'Yemen' => 'Yémen',
'Mayotte' => 'Mayotte',
'South Africa' => 'Afrique du Sud',
'Zambia' => 'Zambie',
'Zimbabwe' => 'Zimbabwe',
'Serbia and Montenegro' => 'Serbie-et-Monténégro',
'Netherlands Antilles' => 'Antilles néerlandaises',
];
// D'abord, essayer avec le nom exact du pays
if (isset($countryNameMapping[$this->countryName])) {
$this->countryNameFr = $countryNameMapping[$this->countryName];
return $this;
}
// Si le nom exact n'est pas trouvé et qu'on a un code ISO, essayer avec Intl
if ($this->isoCode && extension_loaded('intl') && class_exists('Locale')) {
try {
$frenchName = \Locale::getDisplayRegion('-' . $this->isoCode, 'fr');
if ($frenchName && $frenchName !== $this->isoCode && $frenchName !== '-' . $this->isoCode) {
$this->countryNameFr = $frenchName;
return $this;
}
} catch (\Exception $e) {
// Si Intl échoue, on continue avec le mapping par ISO
}
}
// Fallback: mapping par code ISO pour les pays non couverts
$isoCodeMapping = [
'US' => 'États-Unis',
'GB' => 'Royaume-Uni',
'FR' => 'France',
'DE' => 'Allemagne',
'ES' => 'Espagne',
'IT' => 'Italie',
'NL' => 'Pays-Bas',
'BE' => 'Belgique',
'CH' => 'Suisse',
'CA' => 'Canada',
'AU' => 'Australie',
'NZ' => 'Nouvelle-Zélande',
'BR' => 'Brésil',
'MX' => 'Mexique',
'AR' => 'Argentine',
'CL' => 'Chili',
'CO' => 'Colombie',
'PE' => 'Pérou',
'VE' => 'Venezuela',
'PT' => 'Portugal',
'GR' => 'Grèce',
'PL' => 'Pologne',
'CZ' => 'République tchèque',
'SE' => 'Suède',
'NO' => 'Norvège',
'DK' => 'Danemark',
'FI' => 'Finlande',
'IE' => 'Irlande',
'AT' => 'Autriche',
'RU' => 'Russie',
'CN' => 'Chine',
'JP' => 'Japon',
'KR' => 'Corée du Sud',
'IN' => 'Inde',
'SA' => 'Arabie saoudite',
'AE' => 'Émirats arabes unis',
'EG' => 'Égypte',
'ZA' => 'Afrique du Sud',
'MA' => 'Maroc',
'DZ' => 'Algérie',
'TN' => 'Tunisie',
'SN' => 'Sénégal',
'CI' => 'Côte d\'Ivoire',
'CM' => 'Cameroun',
'CD' => 'République démocratique du Congo',
'KE' => 'Kenya',
'NG' => 'Nigeria',
'GH' => 'Ghana',
'ET' => 'Éthiopie',
'TZ' => 'Tanzanie',
'UG' => 'Ouganda',
'RW' => 'Rwanda',
'BF' => 'Burkina Faso',
'ML' => 'Mali',
'NE' => 'Niger',
'TD' => 'Tchad',
'SD' => 'Soudan',
'SO' => 'Somalie',
'DJ' => 'Djibouti',
'ER' => 'Érythrée',
'LY' => 'Libye',
'MR' => 'Mauritanie',
'GM' => 'Gambie',
'GW' => 'Guinée-Bissau',
'GN' => 'Guinée',
'SL' => 'Sierra Leone',
'LR' => 'Liberia',
'TG' => 'Togo',
'BJ' => 'Bénin',
'AO' => 'Angola',
'ZM' => 'Zambie',
'ZW' => 'Zimbabwe',
'BW' => 'Botswana',
'NA' => 'Namibie',
'LS' => 'Lesotho',
'SZ' => 'Eswatini',
'MW' => 'Malawi',
'MZ' => 'Mozambique',
'MG' => 'Madagascar',
'MU' => 'Maurice',
'SC' => 'Seychelles',
'KM' => 'Comores',
'CV' => 'Cap-Vert',
'ST' => 'São Tomé-et-Príncipe',
'GQ' => 'Guinée équatoriale',
'GA' => 'Gabon',
'CG' => 'Congo',
'CF' => 'République centrafricaine',
'TD' => 'Tchad',
'SS' => 'Soudan du Sud',
'BI' => 'Burundi',
'YE' => 'Yémen',
'OM' => 'Oman',
'QA' => 'Qatar',
'BH' => 'Bahreïn',
'KW' => 'Koweït',
'IQ' => 'Irak',
'JO' => 'Jordanie',
'LB' => 'Liban',
'SY' => 'Syrie',
'IL' => 'Israël',
'PS' => 'Palestine',
'TR' => 'Turquie',
'IR' => 'Iran',
'AF' => 'Afghanistan',
'PK' => 'Pakistan',
'BD' => 'Bangladesh',
'LK' => 'Sri Lanka',
'MV' => 'Maldives',
'NP' => 'Népal',
'BT' => 'Bhoutan',
'MM' => 'Myanmar',
'TH' => 'Thaïlande',
'LA' => 'Laos',
'KH' => 'Cambodge',
'VN' => 'Viêt Nam',
'MY' => 'Malaisie',
'SG' => 'Singapour',
'BN' => 'Brunei',
'PH' => 'Philippines',
'ID' => 'Indonésie',
'TL' => 'Timor oriental',
'PG' => 'Papouasie-Nouvelle-Guinée',
'FJ' => 'Fidji',
'NC' => 'Nouvelle-Calédonie',
'PF' => 'Polynésie française',
'WS' => 'Samoa',
'TO' => 'Tonga',
'VU' => 'Vanuatu',
'SB' => 'Îles Salomon',
'KI' => 'Kiribati',
'TV' => 'Tuvalu',
'NR' => 'Nauru',
'PW' => 'Palaos',
'FM' => 'Micronésie',
'MH' => 'Îles Marshall',
'UA' => 'Ukraine',
'BY' => 'Biélorussie',
'LT' => 'Lituanie',
'LV' => 'Lettonie',
'EE' => 'Estonie',
'MD' => 'Moldavie',
'RO' => 'Roumanie',
'BG' => 'Bulgarie',
'RS' => 'Serbie',
'BA' => 'Bosnie-Herzégovine',
'HR' => 'Croatie',
'SI' => 'Slovénie',
'SK' => 'Slovaquie',
'HU' => 'Hongrie',
'AL' => 'Albanie',
'MK' => 'Macédoine du Nord',
'ME' => 'Monténégro',
'XK' => 'Kosovo',
'IS' => 'Islande',
'LU' => 'Luxembourg',
'MT' => 'Malte',
'CY' => 'Chypre',
'AD' => 'Andorre',
'MC' => 'Monaco',
'SM' => 'Saint-Marin',
'VA' => 'Vatican',
'LI' => 'Liechtenstein',
'UY' => 'Uruguay',
'PY' => 'Paraguay',
'BO' => 'Bolivie',
'EC' => 'Équateur',
'GY' => 'Guyana',
'SR' => 'Suriname',
'GF' => 'Guyane française',
'FK' => 'Îles Malouines',
'GS' => 'Géorgie du Sud-et-les Îles Sandwich du Sud',
'CU' => 'Cuba',
'JM' => 'Jamaïque',
'HT' => 'Haïti',
'DO' => 'République dominicaine',
'PR' => 'Porto Rico',
'TT' => 'Trinité-et-Tobago',
'BB' => 'Barbade',
'BS' => 'Bahamas',
'BZ' => 'Belize',
'GT' => 'Guatemala',
'HN' => 'Honduras',
'SV' => 'Salvador',
'NI' => 'Nicaragua',
'CR' => 'Costa Rica',
'PA' => 'Panama',
];
if ($this->isoCode && isset($isoCodeMapping[$this->isoCode])) {
$this->countryNameFr = $isoCodeMapping[$this->isoCode];
} else {
// Si aucun mapping n'est trouvé, on garde le nom anglais
$this->countryNameFr = $this->countryName;
}
return $this;
}
}