Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,84 +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\MessageCatalogue;
15
-
16
-/**
17
- * PoFileDumper generates a gettext formatted string representation of a message catalogue.
18
- *
19
- * @author Stealth35
20
- */
21
-class PoFileDumper extends FileDumper
22
-{
23
-    /**
24
-     * {@inheritdoc}
25
-     */
26
-    public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
27
-    {
28
-        $output = 'msgid ""'."\n";
29
-        $output .= 'msgstr ""'."\n";
30
-        $output .= '"Content-Type: text/plain; charset=UTF-8\n"'."\n";
31
-        $output .= '"Content-Transfer-Encoding: 8bit\n"'."\n";
32
-        $output .= '"Language: '.$messages->getLocale().'\n"'."\n";
33
-        $output .= "\n";
34
-
35
-        $newLine = false;
36
-        foreach ($messages->all($domain) as $source => $target) {
37
-            if ($newLine) {
38
-                $output .= "\n";
39
-            } else {
40
-                $newLine = true;
41
-            }
42
-            $metadata = $messages->getMetadata($source, $domain);
43
-
44
-            if (isset($metadata['comments'])) {
45
-                $output .= $this->formatComments($metadata['comments']);
46
-            }
47
-            if (isset($metadata['flags'])) {
48
-                $output .= $this->formatComments(implode(',', (array) $metadata['flags']), ',');
49
-            }
50
-            if (isset($metadata['sources'])) {
51
-                $output .= $this->formatComments(implode(' ', (array) $metadata['sources']), ':');
52
-            }
53
-
54
-            $output .= sprintf('msgid "%s"'."\n", $this->escape($source));
55
-            $output .= sprintf('msgstr "%s"'."\n", $this->escape($target));
56
-        }
57
-
58
-        return $output;
59
-    }
60
-
61
-    /**
62
-     * {@inheritdoc}
63
-     */
64
-    protected function getExtension()
65
-    {
66
-        return 'po';
67
-    }
68
-
69
-    private function escape($str)
70
-    {
71
-        return addcslashes($str, "\0..\37\42\134");
72
-    }
73
-
74
-    private function formatComments($comments, string $prefix = ''): ?string
75
-    {
76
-        $output = null;
77
-
78
-        foreach ((array) $comments as $comment) {
79
-            $output .= sprintf('#%s %s'."\n", $prefix, $comment);
80
-        }
81
-
82
-        return $output;
83
-    }
84
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,84 @@
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\MessageCatalogue;
15
+
16
+/**
17
+ * PoFileDumper generates a gettext formatted string representation of a message catalogue.
18
+ *
19
+ * @author Stealth35
20
+ */
21
+class PoFileDumper extends FileDumper
22
+{
23
+    /**
24
+     * {@inheritdoc}
25
+     */
26
+    public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
27
+    {
28
+        $output = 'msgid ""'."\n";
29
+        $output .= 'msgstr ""'."\n";
30
+        $output .= '"Content-Type: text/plain; charset=UTF-8\n"'."\n";
31
+        $output .= '"Content-Transfer-Encoding: 8bit\n"'."\n";
32
+        $output .= '"Language: '.$messages->getLocale().'\n"'."\n";
33
+        $output .= "\n";
34
+
35
+        $newLine = false;
36
+        foreach ($messages->all($domain) as $source => $target) {
37
+            if ($newLine) {
38
+                $output .= "\n";
39
+            } else {
40
+                $newLine = true;
41
+            }
42
+            $metadata = $messages->getMetadata($source, $domain);
43
+
44
+            if (isset($metadata['comments'])) {
45
+                $output .= $this->formatComments($metadata['comments']);
46
+            }
47
+            if (isset($metadata['flags'])) {
48
+                $output .= $this->formatComments(implode(',', (array) $metadata['flags']), ',');
49
+            }
50
+            if (isset($metadata['sources'])) {
51
+                $output .= $this->formatComments(implode(' ', (array) $metadata['sources']), ':');
52
+            }
53
+
54
+            $output .= sprintf('msgid "%s"'."\n", $this->escape($source));
55
+            $output .= sprintf('msgstr "%s"'."\n", $this->escape($target));
56
+        }
57
+
58
+        return $output;
59
+    }
60
+
61
+    /**
62
+     * {@inheritdoc}
63
+     */
64
+    protected function getExtension()
65
+    {
66
+        return 'po';
67
+    }
68
+
69
+    private function escape($str)
70
+    {
71
+        return addcslashes($str, "\0..\37\42\134");
72
+    }
73
+
74
+    private function formatComments($comments, string $prefix = ''): ?string
75
+    {
76
+        $output = null;
77
+
78
+        foreach ((array) $comments as $comment) {
79
+            $output .= sprintf('#%s %s'."\n", $prefix, $comment);
80
+        }
81
+
82
+        return $output;
83
+    }
84
+}