Skip to content

Commit 6468cd5

Browse files
committed
feature #5745 [Translation] Ability to format a message catalogue without 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.
2 parents d862ee8 + 7e3ab6f commit 6468cd5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

components/translation/custom_formats.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ will save a few lines::
8585

8686
class MyFormatDumper extends FileDumper
8787
{
88-
protected function format(MessageCatalogue $messages, $domain = 'messages')
88+
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
8989
{
9090
$output = '';
9191

@@ -102,7 +102,16 @@ will save a few lines::
102102
}
103103
}
104104

105-
The :method:`Symfony\\Component\\Translation\\Dumper\\FileDumper::format`
105+
.. sidebar:: Format a message catalogue
106+
107+
.. versionadded:: 2.8
108+
The ability to format a message catalogue without dumping it was introduced in Symfony 2.8.
109+
110+
In some cases, you want to send the dump contents as a response instead of writing them in files.
111+
To do this, you can use the ``formatCatalogue`` method. In this case, you must pass the domain argument,
112+
which determines the list of messages that should be dumped.
113+
114+
The :method:`Symfony\\Component\\Translation\\Dumper\\FileDumper::formatCatalogue`
106115
method creates the output string, that will be used by the
107116
:method:`Symfony\\Component\\Translation\\Dumper\\FileDumper::dump` method
108117
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::
116125

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy