IniFileDumper.php 984 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation\Dumper;
  11. use Symfony\Component\Translation\MessageCatalogue;
  12. /**
  13. * IniFileDumper generates an ini formatted string representation of a message catalogue.
  14. *
  15. * @author Stealth35
  16. */
  17. class IniFileDumper extends FileDumper
  18. {
  19. /**
  20. * {@inheritDoc}
  21. */
  22. public function format(MessageCatalogue $messages, $domain = 'messages')
  23. {
  24. $output = '';
  25. foreach ($messages->all($domain) as $source => $target) {
  26. $escapeTarget = str_replace('"', '\"', $target);
  27. $output .= $source.'="'.$escapeTarget."\"\n";
  28. }
  29. return $output;
  30. }
  31. /**
  32. * {@inheritDoc}
  33. */
  34. protected function getExtension()
  35. {
  36. return 'ini';
  37. }
  38. }