public function dump(
        $target = 'web/js',
        $pattern = self::DEFAULT_TRANSLATION_PATTERN,
        array $formats = array(),
        \stdClass $merge = null
    ) {
        $availableFormats  = array('js', 'json');

        $parts = array_filter(explode('/', $pattern));
        $this->filesystem->remove($target. '/' . current($parts));

        foreach ($formats as $format) {
            if (!in_array($format, $availableFormats)) {
                throw new \RuntimeException('The ' . $format . ' format is not available. Use only: ' . implode(', ', $availableFormats) . '.');
            }
        }

        if (empty($formats)) {
            $formats = $availableFormats;
        }

        $this->dumpConfig($pattern, $formats, $target);

        if ($merge && $merge->domains) {
            $this->dumpTranslationsPerLocale($pattern, $formats, $target);
        } else {
            $this->dumpTranslationsPerDomain($pattern, $formats, $target);
        }
    }