1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,62 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-/* |
|
4 |
- * This file is part of the Symfony package. |
|
5 |
- * |
|
6 |
- * (c) Fabien Potencier <fabien@symfony.com> |
|
7 |
- * |
|
8 |
- * For the full copyright and license information, please view the LICENSE |
|
9 |
- * file that was distributed with this source code. |
|
10 |
- */ |
|
11 |
- |
|
12 |
-namespace Symfony\Component\Translation\Dumper; |
|
13 |
- |
|
14 |
-use Symfony\Component\Translation\Exception\LogicException; |
|
15 |
-use Symfony\Component\Translation\MessageCatalogue; |
|
16 |
-use Symfony\Component\Translation\Util\ArrayConverter; |
|
17 |
-use Symfony\Component\Yaml\Yaml; |
|
18 |
- |
|
19 |
-/** |
|
20 |
- * YamlFileDumper generates yaml files from a message catalogue. |
|
21 |
- * |
|
22 |
- * @author Michel Salib <michelsalib@hotmail.com> |
|
23 |
- */ |
|
24 |
-class YamlFileDumper extends FileDumper |
|
25 |
-{ |
|
26 |
- private $extension; |
|
27 |
- |
|
28 |
- public function __construct(string $extension = 'yml') |
|
29 |
- { |
|
30 |
- $this->extension = $extension; |
|
31 |
- } |
|
32 |
- |
|
33 |
- /** |
|
34 |
- * {@inheritdoc} |
|
35 |
- */ |
|
36 |
- public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) |
|
37 |
- { |
|
38 |
- if (!class_exists('Symfony\Component\Yaml\Yaml')) { |
|
39 |
- throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.'); |
|
40 |
- } |
|
41 |
- |
|
42 |
- $data = $messages->all($domain); |
|
43 |
- |
|
44 |
- if (isset($options['as_tree']) && $options['as_tree']) { |
|
45 |
- $data = ArrayConverter::expandToTree($data); |
|
46 |
- } |
|
47 |
- |
|
48 |
- if (isset($options['inline']) && ($inline = (int) $options['inline']) > 0) { |
|
49 |
- return Yaml::dump($data, $inline); |
|
50 |
- } |
|
51 |
- |
|
52 |
- return Yaml::dump($data); |
|
53 |
- } |
|
54 |
- |
|
55 |
- /** |
|
56 |
- * {@inheritdoc} |
|
57 |
- */ |
|
58 |
- protected function getExtension() |
|
59 |
- { |
|
60 |
- return $this->extension; |
|
61 |
- } |
|
62 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,62 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * This file is part of the Symfony package. |
|
5 |
+ * |
|
6 |
+ * (c) Fabien Potencier <fabien@symfony.com> |
|
7 |
+ * |
|
8 |
+ * For the full copyright and license information, please view the LICENSE |
|
9 |
+ * file that was distributed with this source code. |
|
10 |
+ */ |
|
11 |
+ |
|
12 |
+namespace Symfony\Component\Translation\Dumper; |
|
13 |
+ |
|
14 |
+use Symfony\Component\Translation\Exception\LogicException; |
|
15 |
+use Symfony\Component\Translation\MessageCatalogue; |
|
16 |
+use Symfony\Component\Translation\Util\ArrayConverter; |
|
17 |
+use Symfony\Component\Yaml\Yaml; |
|
18 |
+ |
|
19 |
+/** |
|
20 |
+ * YamlFileDumper generates yaml files from a message catalogue. |
|
21 |
+ * |
|
22 |
+ * @author Michel Salib <michelsalib@hotmail.com> |
|
23 |
+ */ |
|
24 |
+class YamlFileDumper extends FileDumper |
|
25 |
+{ |
|
26 |
+ private $extension; |
|
27 |
+ |
|
28 |
+ public function __construct(string $extension = 'yml') |
|
29 |
+ { |
|
30 |
+ $this->extension = $extension; |
|
31 |
+ } |
|
32 |
+ |
|
33 |
+ /** |
|
34 |
+ * {@inheritdoc} |
|
35 |
+ */ |
|
36 |
+ public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) |
|
37 |
+ { |
|
38 |
+ if (!class_exists('Symfony\Component\Yaml\Yaml')) { |
|
39 |
+ throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.'); |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ $data = $messages->all($domain); |
|
43 |
+ |
|
44 |
+ if (isset($options['as_tree']) && $options['as_tree']) { |
|
45 |
+ $data = ArrayConverter::expandToTree($data); |
|
46 |
+ } |
|
47 |
+ |
|
48 |
+ if (isset($options['inline']) && ($inline = (int) $options['inline']) > 0) { |
|
49 |
+ return Yaml::dump($data, $inline); |
|
50 |
+ } |
|
51 |
+ |
|
52 |
+ return Yaml::dump($data); |
|
53 |
+ } |
|
54 |
+ |
|
55 |
+ /** |
|
56 |
+ * {@inheritdoc} |
|
57 |
+ */ |
|
58 |
+ protected function getExtension() |
|
59 |
+ { |
|
60 |
+ return $this->extension; |
|
61 |
+ } |
|
62 |
+} |