Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions components/translation/custom_formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ will save a few lines::

class MyFormatDumper extends FileDumper
{
protected function format(MessageCatalogue $messages, $domain = 'messages')
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
{
$output = '';

Expand All @@ -102,7 +102,16 @@ will save a few lines::
}
}

The :method:`Symfony\\Component\\Translation\\Dumper\\FileDumper::format`
.. sidebar:: Format a message catalogue

.. versionadded:: 2.8
The ability to format a message catalogue without dumping it was introduced in Symfony 2.8.

In some cases, you want to send the dump contents as a response instead of writing them in files.
To do this, you can use the ``formatCatalogue`` method. In this case, you must pass the domain argument,
which determines the list of messages that should be dumped.

The :method:`Symfony\\Component\\Translation\\Dumper\\FileDumper::formatCatalogue`
method creates the output string, that will be used by the
:method:`Symfony\\Component\\Translation\\Dumper\\FileDumper::dump` method
of the FileDumper class to create the file. The dumper can be used like any other
Expand All @@ -116,4 +125,3 @@ YAML file are dumped into a text file with the custom format::

$dumper = new MyFormatDumper();
$dumper->dump($catalogue, array('path' => __DIR__.'/dumps'));