From 7e3ab6fa0d86329dd9a8a52e6e30626dc1d1f8f8 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Thu, 1 Oct 2015 17:59:14 +0000 Subject: [PATCH] [Translation] Ability to format a message catalogue without dumping it. --- components/translation/custom_formats.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/components/translation/custom_formats.rst b/components/translation/custom_formats.rst index 14c6e65c8b0..1ef3f365553 100644 --- a/components/translation/custom_formats.rst +++ b/components/translation/custom_formats.rst @@ -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 = ''; @@ -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 @@ -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')); -