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 * PoFileDumper generates a gettext formatted string representation of a message catalogue.
21 class PoFileDumper
extends FileDumper
26 public function format(MessageCatalogue
$messages, $domain = 'messages')
30 foreach ($messages->all($domain) as $source => $target) {
36 $output .= sprintf('msgid "%s"'."\n", $this->escape($source));
37 $output .= sprintf('msgstr "%s"', $this->escape($target));
46 protected function getExtension()
51 private function escape($str)
53 return addcslashes($str, "\0..\37\42\134");