comparison vendor/symfony/translation/Dumper/XliffFileDumper.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
9 * file that was distributed with this source code. 9 * file that was distributed with this source code.
10 */ 10 */
11 11
12 namespace Symfony\Component\Translation\Dumper; 12 namespace Symfony\Component\Translation\Dumper;
13 13
14 use Symfony\Component\Translation\Exception\InvalidArgumentException;
14 use Symfony\Component\Translation\MessageCatalogue; 15 use Symfony\Component\Translation\MessageCatalogue;
15 use Symfony\Component\Translation\Exception\InvalidArgumentException;
16 16
17 /** 17 /**
18 * XliffFileDumper generates xliff files from a message catalogue. 18 * XliffFileDumper generates xliff files from a message catalogue.
19 * 19 *
20 * @author Michel Salib <michelsalib@hotmail.com> 20 * @author Michel Salib <michelsalib@hotmail.com>
22 class XliffFileDumper extends FileDumper 22 class XliffFileDumper extends FileDumper
23 { 23 {
24 /** 24 /**
25 * {@inheritdoc} 25 * {@inheritdoc}
26 */ 26 */
27 public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) 27 public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
28 { 28 {
29 $xliffVersion = '1.2'; 29 $xliffVersion = '1.2';
30 if (array_key_exists('xliff_version', $options)) { 30 if (array_key_exists('xliff_version', $options)) {
31 $xliffVersion = $options['xliff_version']; 31 $xliffVersion = $options['xliff_version'];
32 } 32 }
53 protected function getExtension() 53 protected function getExtension()
54 { 54 {
55 return 'xlf'; 55 return 'xlf';
56 } 56 }
57 57
58 private function dumpXliff1($defaultLocale, MessageCatalogue $messages, $domain, array $options = array()) 58 private function dumpXliff1($defaultLocale, MessageCatalogue $messages, $domain, array $options = [])
59 { 59 {
60 $toolInfo = array('tool-id' => 'symfony', 'tool-name' => 'Symfony'); 60 $toolInfo = ['tool-id' => 'symfony', 'tool-name' => 'Symfony'];
61 if (array_key_exists('tool_info', $options)) { 61 if (array_key_exists('tool_info', $options)) {
62 $toolInfo = array_merge($toolInfo, $options['tool_info']); 62 $toolInfo = array_merge($toolInfo, $options['tool_info']);
63 } 63 }
64 64
65 $dom = new \DOMDocument('1.0', 'utf-8'); 65 $dom = new \DOMDocument('1.0', 'utf-8');
127 } 127 }
128 128
129 return $dom->saveXML(); 129 return $dom->saveXML();
130 } 130 }
131 131
132 private function dumpXliff2($defaultLocale, MessageCatalogue $messages, $domain, array $options = array()) 132 private function dumpXliff2($defaultLocale, MessageCatalogue $messages, $domain, array $options = [])
133 { 133 {
134 $dom = new \DOMDocument('1.0', 'utf-8'); 134 $dom = new \DOMDocument('1.0', 'utf-8');
135 $dom->formatOutput = true; 135 $dom->formatOutput = true;
136 136
137 $xliff = $dom->appendChild($dom->createElement('xliff')); 137 $xliff = $dom->appendChild($dom->createElement('xliff'));
193 * 193 *
194 * @return bool 194 * @return bool
195 */ 195 */
196 private function hasMetadataArrayInfo($key, $metadata = null) 196 private function hasMetadataArrayInfo($key, $metadata = null)
197 { 197 {
198 return null !== $metadata && array_key_exists($key, $metadata) && ($metadata[$key] instanceof \Traversable || is_array($metadata[$key])); 198 return null !== $metadata && array_key_exists($key, $metadata) && ($metadata[$key] instanceof \Traversable || \is_array($metadata[$key]));
199 } 199 }
200 } 200 }