菜谱项目

IniFileDumper.php 1006B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
  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. }