IniFileDumper.php 950 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string
  20. {
  21. $output = '';
  22. foreach ($messages->all($domain) as $source => $target) {
  23. $escapeTarget = str_replace('"', '\"', $target);
  24. $output .= $source.'="'.$escapeTarget."\"\n";
  25. }
  26. return $output;
  27. }
  28. protected function getExtension(): string
  29. {
  30. return 'ini';
  31. }
  32. }