Skip to content

Commit

Permalink
feature #5745 [Translation] Ability to format a message catalogue wit…
Browse files Browse the repository at this point in the history
…hout actually writing it. (aitboudad)

This PR was merged into the 2.8 branch.

Discussion
----------

[Translation] Ability to format a message catalogue without actually writing it.

| Q             | A
| ------------- | ---
| Doc fix?        | no
| New docs?   | yes
| Applies to     | all
| Fixed tickets | #5743

Commits
-------

7e3ab6f [Translation] Ability to format a message catalogue without dumping it.
  • Loading branch information
xabbuh committed Oct 5, 2015
2 parents d862ee8 + 7e3ab6f commit 6468cd5
Showing 1 changed file with 11 additions and 3 deletions.
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'));

0 comments on commit 6468cd5

Please sign in to comment.