symfony/translation · error · InvalidArgumentException

There is no dumper associated with format

Error message

There is no dumper associated with format "%s".

What it means

TranslationWriter::write() looks up the dumper registered for the requested format (e.g. 'xlf', 'yml', 'po'). If no dumper has been added for that format string, it throws this InvalidArgumentException. The writer only knows formats registered via addDumper() or formatDumperClasses.

Solutions

  1. Check the exact format string against $writer->getFormats() before writing
  2. Register the missing dumper: $writer->addDumper('xlf', new XliffFileDumper())
  3. Fix typos (e.g. 'xliff' -> 'xlf')

Example fix

// before
$writer->write($catalogue, 'xliff', ['path' => $dir]);
// after
$writer->addDumper('xlf', new XliffFileDumper());
if (in_array('xlf', $writer->getFormats(), true)) {
    $writer->write($catalogue, 'xlf', ['path' => $dir]);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!in_array($format, $writer->getFormats(), true)) {
    throw new \InvalidArgumentException("Unsupported translation format: $format");
}

Type guard

function isValidFormat(TranslationWriter $writer, string $format): bool {
    return in_array($format, $writer->getFormats(), true);
}

Try / catch

try {
    $writer->write($catalogue, $format, $options);
} catch (\InvalidArgumentException $e) {
    $this->logger->error('Unsupported translation format', ['format' => $format, 'msg' => $e->getMessage()]);
}

Prevention

When it happens

Trigger: Calling $writer->write($catalogue, 'xliff', $options) when the dumper was registered as 'xlf' (or vice versa); a typo in the format string; using a format whose dumper class was never added to the writer.

Common situations: Migrating from XliffFileDumper/old format names; hard-coding format strings in CI scripts that dump translations; custom dumpers not registered before write().

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15). Data as JSON: /api/errors/5eb293ff2eb6d8f8. Report an issue: GitHub.

Appendix: source

Thrown at Writer/TranslationWriter.php:58

     * Obtains the list of supported formats.
     */
    public function getFormats(): array
    {
        return array_keys($this->dumpers);
    }

    /**
     * Writes translation from the catalogue according to the selected format.
     *
     * @param string $format  The format to use to dump the messages
     * @param array  $options Options that are passed to the dumper
     *
     * @throws InvalidArgumentException
     */
    public function write(MessageCatalogue $catalogue, string $format, array $options = []): void
    {
        if (!isset($this->dumpers[$format])) {
            throw new InvalidArgumentException(\sprintf('There is no dumper associated with format "%s".', $format));
        }

        // get the right dumper
        $dumper = $this->dumpers[$format];

        if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0o777, true) && !is_dir($options['path'])) {
            throw new RuntimeException(\sprintf('Translation Writer was not able to create directory "%s".', $options['path']));
        }

        // save
        $dumper->dump($catalogue, $options);
    }
}

View on GitHub (pinned to ae9e8a51bc)