4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation\Dumper;
14 use Symfony\Component\Translation\MessageCatalogue;
17 * CsvFileDumper generates a csv formatted string representation of a message catalogue.
21 class CsvFileDumper extends FileDumper
23 private $delimiter = ';';
24 private $enclosure = '"';
29 public function format(MessageCatalogue $messages, $domain = 'messages')
31 @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
33 return $this->formatCatalogue($messages, $domain);
39 public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
41 $handle = fopen('php://memory', 'rb+');
43 foreach ($messages->all($domain) as $source => $target) {
44 fputcsv($handle, array($source, $target), $this->delimiter, $this->enclosure);
48 $output = stream_get_contents($handle);
55 * Sets the delimiter and escape character for CSV.
57 * @param string $delimiter delimiter character
58 * @param string $enclosure enclosure character
60 public function setCsvControl($delimiter = ';', $enclosure = '"')
62 $this->delimiter = $delimiter;
63 $this->enclosure = $enclosure;
69 protected function getExtension()