---
title: "Feature: #104168 - PSR-14 event for modifying countries"
manual: "TYPO3 Core Changelog"
version: "main"
permalink: "https://docs.typo3.org/permalink/changelog:feature-104168-1719373149"
source: "Changelog/13.3/Feature-104168-PSR-14EventForModifyingCountries.rst"
typo3-version: "13.3"
typo3-major: 13
type: "feature"
issue: 104168
forge: "https://forge.typo3.org/issues/104168"
tags: ["PHP-API", "ext:core"]
rendered: "2026-09-29T06:32:46+00:00"
---

# Feature: #104168 - PSR-14 event for modifying countries {#feature-104168-1719373149}

See [forge#104168](https://forge.typo3.org/issues/104168)

## Description {#description}

A new PSR-14 event `\TYPO3\CMS\Core\Country\Event\BeforeCountriesEvaluatedEvent`
has been introduced to modify the list of countries provided by
`\TYPO3\CMS\Core\Country\CountryProvider`.

This event allows to add, remove and alter countries from the list used by the
provider class itself and ViewHelpers like `<f:form.countrySelect />`.

> [!NOTE]
> The DTO `\TYPO3\CMS\Core\Country\Country`
> uses `EXT:core/Resources/Private/Language/Iso/countries.xlf` for translating
> the country names.
>
> If additional countries are added, add translations to `countries.xlf`
> via [locallangXMLOverride](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Localization/ManagingTranslations.html#xliff-translating-custom).

## Example {#example}

An example corresponding event listener class:

```php
<?php
declare(strict_types=1);

namespace MyVendor\MyExtension\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Country\Country;
use TYPO3\CMS\Core\Country\Event\BeforeCountriesEvaluatedEvent;

final readonly class EventListener
{
    #[AsEventListener(identifier: 'my-extension/before-countries-evaluated')]
    public function __invoke(BeforeCountriesEvaluatedEvent $event): void
    {
        $countries = $event->getCountries();
        unset($countries['BS']);
        $countries['XX'] = new Country(
            'XX',
            'XYZ',
            'Magic Kingdom',
            '987',
            '🔮',
            'Kingdom of Magic and Wonders'
        );
        $event->setCountries($countries);
    }
}
```

**EXT:my_extension/ext_localconf.php**

```php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']
    ['EXT:core/Resources/Private/Language/Iso/countries.xlf'][]
        = 'EXT:my_extension/Resources/Private/Language/countries.xlf';
```

**EXT:my_extension/Resources/Private/Language/countries.xlf**

```xml
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
    <file source-language="en" datatype="plaintext" date="2024-01-08T18:44:59Z" product-name="my_extension">
        <body>
            <trans-unit id="XX.name" approved="yes">
                <source>Magic Kingdom</source>
            </trans-unit>
            <trans-unit id="XX.official_name" approved="yes">
                <source>Kingdom of Magic and Wonders</source>
            </trans-unit>
        </body>
    </file>
</xliff>
```

## Impact {#impact}

Using the PSR-14 event `\TYPO3\CMS\Core\Country\Event\BeforeCountriesEvaluatedEvent` allows
modification of countries provided by `\TYPO3\CMS\Core\Country\CountryProvider`.
