public function updateFromCatalog(): void
    {
        $domain = $this->params['domain'];

        $localePath = ROOT . '/src/Locale/';

        $catalogFile = $localePath . $domain . '.pot';
        if (!file_exists($catalogFile)) {
            $this->abort(sprintf('Catalog File %s not found.', $catalogFile));
        }

        $poFiles = [];
        $folder = new Folder($localePath);
        $tree = $folder->tree();

        foreach ($tree[1] as $file) {
            $basename = basename($file);
            if ($domain . '.po' === $basename) {
                $poFiles[] = $file;
            }
        }
        if (empty($poFiles)) {
            $this->abort(sprintf('I could not find any matching po files in the given locale path (%s) for the domain (%s)', $localePath, $domain));
        }

        if (!$this->params['overwrite']) {
            $this->out('I will update the following .po files and their corresponding .mo file with the keys from catalog: ' . $catalogFile);
            foreach ($poFiles as $poFile) {
                $this->out('    - ' . $poFile);
            }
            $response = $this->in('Would you like to continue?', ['y', 'n'], 'n');
            if ($response !== 'y') {
                $this->abort('Aborted');
            }
        }

        foreach ($poFiles as $poFile) {
            $catalogEntries = Translations::fromPoFile($catalogFile);
            $moFile = str_replace('.po', '.mo', $poFile);
            $translationEntries = Translations::fromPoFile($poFile);

            $newTranslationEntries = $catalogEntries->mergeWith($translationEntries, Merge::REFERENCES_THEIRS);

            $newTranslationEntries->deleteHeaders();
            foreach ($translationEntries->getHeaders() as $key => $value) {
                $newTranslationEntries->setHeader($key, $value);
            }

            if ($this->params['strip-references']) {
                foreach ($newTranslationEntries as $translation) {
                    $translation->deleteReferences();
                }
            }

            $newTranslationEntries->toPoFile($poFile);
            $newTranslationEntries->toMoFile($moFile);
            $this->out('Updated ' . $poFile);
            $this->out('Updated ' . $moFile);
        }
    }