1 | <?php |
||
28 | final class XliffDumper extends XliffFileDumper |
||
29 | { |
||
30 | /** |
||
31 | * @var SymfonyPort|null |
||
32 | */ |
||
33 | private $sfPort; |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | 3 | public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) |
|
39 | { |
||
40 | 3 | $xliffVersion = '1.2'; |
|
41 | 3 | if (array_key_exists('xliff_version', $options)) { |
|
42 | 3 | $xliffVersion = $options['xliff_version']; |
|
43 | } |
||
44 | |||
45 | 3 | if (array_key_exists('default_locale', $options)) { |
|
46 | $defaultLocale = $options['default_locale']; |
||
47 | } else { |
||
48 | 3 | $defaultLocale = \Locale::getDefault(); |
|
49 | } |
||
50 | |||
51 | 3 | if ('1.2' === $xliffVersion) { |
|
52 | 1 | if (method_exists($this, 'dumpXliff1')) { |
|
53 | 1 | return NSA::invokeMethod($this, 'dumpXliff1', $defaultLocale, $messages, $domain, $options); |
|
54 | } else { |
||
55 | // Symfony 2.7 |
||
56 | return $this->format($messages, $domain); |
||
57 | } |
||
58 | } |
||
59 | |||
60 | 2 | if ('2.0' === $xliffVersion) { |
|
61 | 2 | if (null === $this->sfPort) { |
|
62 | 2 | $this->sfPort = new SymfonyPort(); |
|
63 | } |
||
64 | |||
65 | 2 | return $this->sfPort->dumpXliff2($defaultLocale, $messages, $domain, $options); |
|
66 | } |
||
67 | |||
68 | throw new InvalidArgumentException( |
||
69 | sprintf('No support implemented for dumping XLIFF version "%s".', $xliffVersion) |
||
70 | ); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * To support Symfony 2.7. |
||
75 | */ |
||
76 | protected function format(MessageCatalogue $messages, $domain) |
||
80 | } |
||
81 |