src/Translation/FilesystemUpdater.php
public function onTerminate(Event $event)
    {
        if (empty($this->messages)) {
            return;
        }

        /** @var MessageCatalogue[] $catalogues */
        $catalogues = array();
        foreach ($this->messages as $m) {
            $key = $m->getLocale().$m->getDomain();
            if (!isset($catalogues[$key])) {
                $file = sprintf('%s/%s.%s.%s', $this->targetDir, $m->getDomain(), $m->getLocale(), $this->getFileExtension());
                
                try {
                    $catalogues[$key] = $this->loader->load($file, $m->getLocale(), $m->getDomain());
                } catch (NotFoundResourceException $e) {
                    $catalogues[$key] = new MessageCatalogue($m->getLocale());
                }
            }

            $translation = $m->getTranslation();
            if (empty($translation)) {
                if ($this->syncEmptyTranslations) {
                    $translation = sprintf('[%s]', $m->getId());
                } else {
                    continue;
                }
            }

            $catalogues[$key]->set($m->getId(), $translation, $m->getDomain());
        }

        foreach ($catalogues as $catalogue) {
            try {
                $this->dumper->dump($catalogue, ['path' => $this->targetDir]);
            } catch (\ErrorException $e) {
                // Could not save file
                // TODO better error handling
                throw $e;
            }
        }
    }
public function onTerminate(Event $event)
    {
        if (empty($this->messages)) {
            return;
        }

        /** @var MessageCatalogue[] $catalogues */
        $catalogues = array();
        foreach ($this->messages as $m) {
            $key = $m->getLocale().$m->getDomain();
            if (!isset($catalogues[$key])) {
                $file = sprintf('%s/%s.%s.%s', $this->targetDir, $m->getDomain(), $m->getLocale(), $this->getFileExtension());
                
                try {
                    $catalogues[$key] = $this->loader->load($file, $m->getLocale(), $m->getDomain());
                } catch (NotFoundResourceException $e) {
                    $catalogues[$key] = new MessageCatalogue($m->getLocale());
                }
            }

            $translation = $m->getTranslation();
            if (empty($translation)) {
                if ($this->syncEmptyTranslations) {
                    $translation = sprintf('[%s]', $m->getId());
                } else {
                    continue;
                }
            }

            $catalogues[$key]->set($m->getId(), $translation, $m->getDomain());
        }

        foreach ($catalogues as $catalogue) {
            try {
                $this->dumper->dump($catalogue, ['path' => $this->targetDir]);
            } catch (\ErrorException $e) {
                // Could not save file
                // TODO better error handling
                throw $e;
            }
        }
    }
Update the file system after the Response has been sent back to the client.

@param Event $event

@throws \ErrorException
@throws \Exception